Reputation: 141
How to create dynamic route when using ui router,
if we define:
$stateProvider.state('page1', {
url: '/page1/:id',
views:{}
}
It works fine,
But if we try to add dynamic id first and then page name then it gives error,
ERROR:
$stateProvider.state('page1', {
url: '/:id/page1',
views:{}
}
How to resolve this issue, can anyone help me into this?
Upvotes: 1
Views: 139
Reputation: 6263
Ok so based on your comment you should use something like this:
$stateProvider
.state('page1', {
url: '/:id/page1'
});
The part above was just fine. But in your link you should use something like this:
<a ui-sref="page1({id: '1234'})">page1</a>
You can also set a variable to the ui-sref
like:
<a ui-sref="page1({id: page.id})">page1</a>
Upvotes: 1