Reputation: 18144
I've seen this in a codebase:
.state('product', {
url: productPageUrl + '/:slug',
params: {
productId: null,
color: null,
size: null,
product: null
},
...
},
...
What does it mean?
All data after /
will be slug, right?
But accessing $stateParams['productId'] returns correct id. ex: for url:
/product/product-name-homme-170758.html
return 170758
for $stateParams['productId']
.
Upvotes: 2
Views: 34
Reputation: 2341
params
defines non URL-route parameters. They just simply don't appear in the URL. In your case slug
should be equal to product-name-homme-170758.html
, and the productId
is simply set with ui-sref
or $state.go
In your example, it would be:
ui-sref="product({ slug: 'product-name-homme-170758.html', productId: 170758 })"
Upvotes: 2