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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -