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
?
使用括号进行过滤:
<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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.