How to use a wild card for part of the path in Angular router? -




i have following routing setup.

const routes: routes = [   { path: "submenu1", component: submenucomponent, outlet: "menus" },   { path: "submenu2", component: submenucomponent, outlet: "menus" },   { path: "submenu3", component: submenucomponent, outlet: "menus" },   ... ]; 

i tried use wild card ** match starting submenu in following way. sadly, seem not match way , no routing @ all.

const routes: routes = [   { path: "submenu**", component: submenucomponent, outlet: "menus" },   //{ path: "submenu1", component: submenucomponent, outlet: "menus" },   //{ path: "submenu2", component: submenucomponent, outlet: "menus" },   //{ path: "submenu3", component: submenucomponent, outlet: "menus" },   ... ]; 

how do that?

how following ?

const routes: routes = [   { path: "submenu1", component: submenucomponent, outlet: "menus" },   { path: "submenu2", redirectto: 'submenu'},   { path: "submenu3", redirectto: 'submenu'}, ]; 

or if doesn't bother put router listener on app component:

ngoninit() {          if (isplatformbrowser) {             this.routersubscription = this.router.events                 .filter(event => event instanceof navigationend)                 .subscribe(() => {                     if(this.router.url.startswith('submenu'){                         this.router.navigate(['submenu1']);                     };                 });         }     }      ngondestroy() {         this.routersubscription.unsubscribe();     } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -