angular - In Angular2 routing, with new router, how do i redirect empty path only? -
environment: rc4 new router
i have following router config ..
export const routes: routerconfig = [ {path: 'search-documents', component: searchdocumentscomponent}, { path: '', pathmatch: 'prefix', redirectto: '/search-documents' }, {path: '**', component: notfoundcomponent} ]; it works follows ...
http://server ------------------> http://server/search-documents
http://server/ -----------------> http://server/search-documents
http://server/does-not-exist ---> http://server/search-documents
but want ...
http://server ------------------> http://server/search-documents
http://server/ -----------------> http://server/search-documents
http://server/does-not-exist ---> notfoundcomponent
how achieve please?
additional info:
if remove ..
{ path: '', pathmatch: 'prefix', redirectto: '/search-documents' } i ..
http://server ------------------> notfoundcomponent
http://server/ -----------------> notfoundcomponent
http://server/does-not-exist ---> notfoundcomponent
use full instead of prefix
pathmatch: 'full', prefix tells router continue looking matching routes while full makes consume full path , stop searching matches.
Comments
Post a Comment