使用 ui-sref 的站点导航,不可用时如何删除 ui-sref 属性 [英] Site navigation using ui-sref, how to remove ui-sref attribute when not available
问题描述
我使用 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.
问题是对于那些特殊情况,当没有可用状态时,我需要一起删除 ui-sref,因为根本不应该有链接.有了它就会抛出错误:无效状态引用"
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 can use {{}}
with expression
You could use {{}}
with expression
标记
ui-sref="{{expression ? '.childState' : '.'}}"
.
会创建自己的状态路由,所以当点击它时,它不会重定向到任何地方.
.
will create own state route, so while click on it, it will redirect no where.
希望能帮到你,谢谢.
这篇关于使用 ui-sref 的站点导航,不可用时如何删除 ui-sref 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!