javascript - Angular 2 - Child route have a different parent component to parent component -


hi i've got routes file set this

const routes: routes = [      { path: '', component: parentcomponent, canactivate: [ loggedinguard ], children: [          { path: 'profile', component: profilecomponent },          { path: 'sign-out', component: signoutcomponent },          { path: 'set-password', component: setpasswordcomponent },          { path: '', canactivate: [ lastlogindateguard ], children: [              { path: 'admin', canactivate: [ adminguard ], children: [                  { path: 'event/:event_id',  component: appcomponent,  children: [                      { path: '', component: eventcomponent }                  ]},              ]},          ]},          { path: '', redirectto: '/sign-in', pathmatch: 'full' },      ]},      { path: '', component: appcomponent },      { path: 'home', component: homecomponent },      { path: 'sign-in', component: signincomponent },      { path: 'sign-up', component: signupcomponent },      { path: '**', component: pagenotfoundcomponent }  ];

what need event/:event_id route have different parent component normal parentcomponent

{ path: 'admin', canactivate: [ adminguard ], children: [    { path: 'event/:event_id',  component: appcomponent,  children: [      { path: '', component: eventcomponent }    ]},  ]},

i want parent component of event/:event_id appcomponent not parentcompnent

for need remove whole route part parentcomponent child , make parent of appcomponent,

please try route setting :

const routes: routes = [     { path: '', component: parentcomponent, canactivate: [ loggedinguard ], children: [         { path: 'profile', component: profilecomponent },         { path: 'sign-out', component: signoutcomponent },         { path: 'set-password', component: setpasswordcomponent },         { path: '', redirectto: '/sign-in', pathmatch: 'full' }      ]},      { path: '', canactivate: [ loggedinguard ], children: [         { path: '', canactivate: [ lastlogindateguard ], children: [             { path: 'admin', component: appcomponent, canactivate: [ adminguard ], children: [                 { path: 'event/:event_id' ,  children: [                     { path: '', component: eventcomponent }                 ]},             ]},         ]}     ]},      { path: '', component: appcomponent },     { path: 'home', component: homecomponent },     { path: 'sign-in', component: signincomponent },     { path: 'sign-up', component: signupcomponent },     { path: '**', component: pagenotfoundcomponent } ]; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -