简体   繁体   English

在ui-sref中过滤

[英]Filter in ui-sref

I am trying to apply a filter on a parameter in my ui-sref reference. 我正在尝试对我的ui-sref引用中的参数应用过滤器。

<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 ? 如何将slugify过滤器应用于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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM