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

查看:30
本文介绍了在 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天全站免登陆