Filter in ui-sref

耗尽温柔 提交于 2019-12-10 23:29:51

问题


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?


回答1:


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);
}



回答2:


Use parentheses for filter:

<a ui-sref="item.show({ itemId: item.id, itemName: (item.name | slugify) })">


来源:https://stackoverflow.com/questions/23494358/filter-in-ui-sref

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!