0

Is it possible to get parent route instructions in some child component?

I try to create some breadcrumbs component and I can get route instruction for current component and for his child, but I have no idea how to get parent route instruction (it`s very important, because when I insert some path in URL and move to them, breadcrumbs should get all route tree data for correct self-rendering, not only the current component).

I use this way to get current route instr. It`s normal or some better way exist?

constructor(private _router: Router) { }

ngOnInit() {
    this._router.subscribe((value) => {
      this._router.recognize(value).then(instruction => {
        let component = instruction.component,
          crumb = component.routeData.get('routeLabel');

        this.crumbsGenerate(crumb);
      });
}

Please, help me. Thanks.

Velidan
  • 5,526
  • 10
  • 48
  • 86
  • Dup of http://stackoverflow.com/questions/35570624/how-to-implement-breadcrumb-using-angular2s-router ? – Günter Zöchbauer Apr 08 '16 at 10:06
  • It`s not a duplicate. Because I want to know how to get parent level route instructions. – Velidan Apr 08 '16 at 10:13
  • Not found correct answer (maybe I ask incorrect question, I don`t know) so I resolved my issue with hard force. Just concatenated and handled data from my current instructions. – Velidan Apr 08 '16 at 13:36
  • There is currently just no easy answer. There is a bigger rework planned for the router and the API will be improved. But such things take some time. – Günter Zöchbauer Apr 08 '16 at 13:37
  • Thanks Gunter for your answer=) I will wait :) – Velidan Apr 08 '16 at 13:40
  • The wait is over: http://stackoverflow.com/questions/38312417/angular2-router-get-route-data-from-url-to-display-breadcrumbs – Mark Rajcok Aug 07 '16 at 05:41

0 Answers0