I am trying to apply a filter on a parameter in my ui-sref
reference.
<a ui-sref="item.show({ itemId: item.id, itemName: item.name | slugify })">
However, the above is not working. How to I apply the slugify
filter to item.name
?
I am trying to apply a filter on a parameter in my ui-sref
reference.
<a ui-sref="item.show({ itemId: item.id, itemName: item.name | slugify })">
However, the above is not working. How to I apply the slugify
filter to item.name
?
2 Answers
Reset to default 9Use parentheses for filter:
<a ui-sref="item.show({ itemId: item.id, itemName: (item.name | slugify) })">
You can use a function:
<a ui-sref="item.show({ itemId: item.id, itemName: getSlugifiedName(item) })">
And in your controller, something like that:
$scope.getSlugifiedName = function (item) {
return $filter('slugify')(item.name);
}