使用ui-sref的网站导航,如果不可用,如何删除ui-sref属性 [英] Site navigation using ui-sref, how to remove ui-sref attribute when not available

查看:90
本文介绍了使用ui-sref的网站导航,如果不可用,如何删除ui-sref属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ng-repeat设置了如下导航,效果很好

I've setup navigation as follows, using ng-repeat, which works very well

<a ui-sref="{{link.Route}}" ng-click="clickLink(link)">
    <span class="title"> {{link.Text}} </span><span class="selected"></span>
</a>

但是,我的导航项经常具有子链接,这意味着父链接并不是真正的导航链接,它仅用于展开和查看子链接。但是有时它是一个链接,并且没有要显示的子链接。

However, my navigation items frequently have sublinks, which means the parent link isn't really a navigation link, it's just used to expand and view the sublinks. But sometime it is a link, and has no sublinks to display.

问题是在那些特殊情况下,当没有可用状态时,我需要删除用户界面-sref全部在一起,因为根本不应该有链接。在那里扔了'错误:无效的状态ref'''

The problem is for those particular cases, when there is no state available, I need to remove the ui-sref all together, because there shouldn't be a link at all. Having it there is throwing 'Error: Invalid state ref '''

当状态不可用时,如何删除ui-sref?

How do I remove the ui-sref when a state isn't available?

推荐答案

您可以在表达式中使用 {{}}

You could use {{}} with expression

标记

ui-sref="{{expression ? '.childState' : '.'}}"

将创建自己的状态路由,因此在单击它时,它将不会重定向到任何地方。

. will create own state route, so while click on it, it will redirect no where.

希望这对您有所帮助,谢谢。

Hope this could help you, Thanks.

这篇关于使用ui-sref的网站导航,如果不可用,如何删除ui-sref属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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