过滤ui-sref [英] Filter in ui-sref

查看:53
本文介绍了过滤ui-sref的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ui-sref参考中的参数上应用过滤器.

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

但是,以上操作无效.如何将slugify过滤器应用于item.name?

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: getSlugifiedName(item) })">

在您的控制器中,类似这样的内容:

And in your controller, something like that:

$scope.getSlugifiedName = function (item) {
    return $filter('slugify')(item.name);
}

这篇关于过滤ui-sref的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆