How do I get the RouteParams from a parent component?
App.ts
:
@Component({
...
})
@RouteConfig([
{path: \'/\', component: HomeCompo
I found an ugly but working solution, by requesting the parent (precisely the 2nd ancestor) injector, and by getting the RouteParams
from here.
Something like
@Component({
...
})
export class ChildOneComponent {
public username: string;
constructor(injector: Injector) {
let params = injector.parent.parent.get(RouteParams);
this.username = params.get('username');
}
}