I am mapping templates
.state('tab.details', {
url: '/details',
views: {
'tab-home': {
templateUrl: 'templates/details.html',
controller: "controllerName"
}
}
})
Now is there a way where I can specify that url:"/details/*"
, i.e i basically want to map whatever url contains details/ to this controller. For example, my code works when i have www.mysite.com/#tab/details?querystring
but its going to default page when i have www.mysite.com/#tab/details/querystring
How can i do it?
You want to use url parameters url: '/details/:query'
You can then access that in the controller by injection $stateParams
and calling $stateParams.query
After implementing Long Nguyen's answer, I faced one more problem
The url changed from
www.site.com/purchase?ItemId=xxx
to www.site.com/purchase/xxx
But i wanted it to change to
www.site.com/purchase/item-name/xxx
(for SEO optimization)
To do that
I changed the url from url: '/details/:query'
to url: '/details/:query/:name'