angular - angular2 sub navigation bar, routing, and path parameters -


i have following urls:

business/details/contacts/:id

business/details/account/:id

business/details/address/:id

and in routing have following:

const routes: routes = [      {          path: 'details',          component: businessdetailscomponent,          children: [              {                  path: 'contacts/:id',                  component: businesscontactdetailscomponent              },              {                  path: 'account/:id',                  component: businessaccountdetailscomponent              },              {                  path: 'address/:id',                  component: businessaddressdetailscomponent              }          ]      }  ];

the idea businessdetailscomponent has navigation bar navigate between 3 pages.

my problem navigation bar in parent needs id child routes. have tried businessdetailscomponent using code below, doesn't work. works in children, not in parent. have ideas?

    ngoninit(): void {          this.route.params.subscribe(params => {              console.log(params);          });         }

as workaround, had following hack:

ngoninit(): void {     // hack don't - need find better way!     if (this.route.children != null) {         this.route.children[0].params.foreach((params: params) => {             this.id = params['id'];         });     } } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -