You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
When you generate absolute url for a route that is registered globally in AppRouter and you are using a ChildRouter for url generation i.e.
// router is injected into component, in this case it's a child routerthis.router.generate('global-route',null,{absolute: true});
The following code will not generate an absolute url, but only a relative url i.e. /some-route/something.
Expected/desired behavior:
Expected behaviour is to have an absolute url generated by router.generate method i.e. https://some-domain.com/some-route/something or http://localhost:9000/some-route/something.
Issue investigation:
In router.js file there is a method generate used for this purpose. Issue is in line 274 => Router line 274 . When the route is not found in the current router (in this case a child router), generate method is invoking itself on the parent router to find this route in his configuration.
generate(name: string,params?: any,options?: any={}): string{lethasRoute=this._recognizer.hasRoute(name);if((!this.isConfigured||!hasRoute)&&this.parent){returnthis.parent.generate(name,params);}if(!hasRoute){thrownewError(`A route with name '${name}' could not be found. Check that \`name: '${name}'\` was specified in the route's config.`);}letpath=this._recognizer.generate(name,params);letrootedPath=_createRootedPath(path,this.baseUrl,this.history._hasPushState,options.absolute);returnoptions.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;}
The method call below doesn't pass options parameter, thus url generated by a parent router is not absolute, because options object is an empty object literal.
returnthis.parent.generate(name,params);
Seems that this issue could be fixed by adding missing parametr to the method call
returnthis.parent.generate(name,params,options);
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
Library Version:
1.6.1
Current behavior:
When you generate absolute url for a route that is registered globally in AppRouter and you are using a ChildRouter for url generation i.e.
The following code will not generate an absolute url, but only a relative url i.e.
/some-route/something
.Expected/desired behavior:
Expected behaviour is to have an absolute url generated by
router.generate
method i.e.https://some-domain.com/some-route/something
orhttp://localhost:9000/some-route/something
.Issue investigation:
In
router.js
file there is a methodgenerate
used for this purpose. Issue is in line 274 => Router line 274 . When the route is not found in the current router (in this case a child router), generate method is invoking itself on the parent router to find this route in his configuration.The method call below doesn't pass options parameter, thus url generated by a parent router is not absolute, because options object is an empty object literal.
Seems that this issue could be fixed by adding missing parametr to the method call
The text was updated successfully, but these errors were encountered: