angularjs - Angular ui-router dynamic params double slash -


i have ui-router's config below:

.state('xxx.components',{             url: '/:runid/component',             reloadonsearch: false,             templateurl: '/modules/xxx//views/cloud-components/templates/cloud-components.tpl.html',             controller: 'cloudcomponentsctrl',             controlleras: 'ctrl'         }) 

if go component page without runid, url below:

http://localhost:3031/xxx/run-topologies//component 

it contain double slash in url, want contains 1 slash below, should can solve issue?

expect behavior:

with runid: (this correct due current config)

http://localhost:3031/xxx/run-topologies/6/component 

without runid: (should 1 slash)

http://localhost:3031/xxx/run-topologies/component 

what asking not possible afaik. but, there 2 ways might interested in use cloudcomponentsctrl both routes.

  1. define separate state url without runid

    .state('xxx.components',{     url: '/component',     reloadonsearch: false,     templateurl: '/modules/xxx/views/cloud-components/templates/cloud-components.tpl.html',     controller: 'cloudcomponentsctrl',     controlleras: 'ctrl' }) .state('xxx.componentsforrunid',{     url: '/:runid/component',     reloadonsearch: false,     templateurl: '/modules/xxx/views/cloud-components/templates/cloud-components.tpl.html',     controller: 'cloudcomponentsctrl',     controlleras: 'ctrl' }) 
  2. remove runid route , include query parameter.

    .state('xxx.components',{     url: '/component?runid',     reloadonsearch: false,     templateurl: '/modules/xxx/views/cloud-components/templates/cloud-components.tpl.html',     controller: 'cloudcomponentsctrl',     controlleras: 'ctrl' }) 

    then can access runid in $stateparams.

hope addresses problem in way.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -