Is it possible to transparently convert URL parameters? How hard it is to explain, I will give a script. We have a URL structure like this:
/shopping/nuts/:productId
/shopping/berries/:productId
/shopping/juice/:productId
Our products shown in the app (supplied by some APIs) might look something like this:
{ type: 'berry', price: 123, text: 'lorem ipsum', id: '12345' }
Note the mismatch between singular and plural: the URL contains the plural, for example. "berries", while the products supplied by our REST API use a special form of "berry".
Part of our state definition looks something like this:
.state('shop.product', {
url: '/shopping/:type/:productId',
templateUrl: 'type.html',
controller: 'TypeController'
})
: $state (toSingular($stateParams.type)), . .
, -
URL /shopping/berries/12345 $stateParams.type === 'berry', URL- ui-sref="shop.product({type: 'berry', id: '12345'})" URL /shopping/berries/12345.
, , . !