javascript - Angular4 - Routing with optional parameters and query parameters -


in angular4 routing, trying navigate specific path optional parameters not navigating correct path, please see below code

routes have configured

{ path:"login",component:"logincomponent"},  {path:"register",component:"registercomponent"},  {path:"**",redirectto:"register"} 

i routing login below this.router.navigate(["login",{optionalparam:"param"}]) navigating register, observe in router debugging url redirects "login;optionalparam=param" "register". issue, facing same issue queryparameters also.

i have done simple example: https://plnkr.co/edit/f3mfg9jxhzeayzz6xzjf.

with redirection , query.

let routes: routes = [     { path: '', component: maincomponent },     { path: 'login',component: logincomponent},     { path: 'redirection',component: redirectcomponent},     { path: '**',redirectto: 'redirection'} ]; 

and

<a [routerlink]="['/login',{'plop':'pom'}]">go login query</a> 

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 -