最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Filter in ui-sref - Stack Overflow

programmeradmin0浏览0评论

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?

Share Improve this question asked May 6, 2014 at 12:11 Patrick ReckPatrick Reck 11.4k11 gold badges56 silver badges88 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Use 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);
}
发布评论

评论列表(0)

  1. 暂无评论