Reputation: 4791
I am using states to go from page to page. From one of URLs I am reading parameter from URL (id) and I can easily do this when defining state.
.config(function($stateProvider) {
$stateProvider
.state("testing", {
url: "/testSession/:id",
controller: "UserTestSessionController",
templateUrl: "./app/components/userTestSession/user-test-session.html",
controllerAs: "vm"
})
})
My URL looked like this: localhost:8000\testSession\id
If I change URL to look like this: localhost:8000\testSession\id?otp="someStringValue"
can I somehow define otp in url param of state? Or do I need to change it totally?
Upvotes: 0
Views: 71
Reputation: 13953
You can just add ?opt
to the url
If you need to have more than one, separate them with an '&'
.config(function($stateProvider) {
$stateProvider
.state("testing", {
url: "/testSession/:id?otp",
controller: "UserTestSessionController",
templateUrl: "./app/components/userTestSession/user-test-session.html",
controllerAs: "vm"
})
})
Upvotes: 2