3gwebtrain 3gwebtrain - 1 month ago 9
AngularJS Question

How to add parameter in state `url` in angularjs

I am trying to add a parameter to my angular application. actually my app will dynamically called as :

"https://abc.ss.com/xx/sn=1234568505


to handle this
state
- in my
$stateProvider
- I am trying like this:

.state('serialCreateCase', {
url: '/sn=*', //but not working
templateUrl:'abxy.html',
controller: 'controllersss as ctrl',
}
})


But my URL is not capturing redirecting to default page. how to add the
=
parameter?

rrd rrd
Answer

Try this:

.state('serialCreateCase', {
  url: '^/sn={id}',
  params: {
    id: {}
  },
  templateUrl:'abxy.html',
  controller: 'controllersss as ctrl',
}

That should match the url you're expecting.

Edit: answer has been updated to change it to required parameters.