typescript - Route with children cannot be match, when navigating to it -
good day. can't understand how new routes children work in angular 2 rc 4. want route testcomponent, have child, error "cannot match route 'test'" appear. routing way: this.guide.navigate(['test']);. how declare routes:
const routes: routerconfig = [ { path: '', component: logincomponent }, { path: 'pin', component: pincomponent, }, { path: 'test', component: testcomponent, children: [ { path: '/:page', component: foodcomponent } ] } ] export const mainrouterproviders = [ providerouter(routes) ]; i cannot use page default in test (like "path: '/'") because children tabs , list loading in testcomponent's constructor.
there few things
add
pathmatch: 'full',first route, otherwise example/pingsearch child routepinginlogincomponentadd default route
testredirects default id or dummy component. angular doesn't if component has<router-outlet>no route add component.
const routes: routerconfig = [ { path: '', pathmatch: 'full', component: logincomponent }, { path: 'pin', component: pincomponent, }, { path: 'test', component: testcomponent, children: [ { path: '', pathmatch: 'full', redirectto: 'mydefaultid' // or // component: dummycomponent }, { path: '/:page', component: foodcomponent } ] } ];
Comments
Post a Comment