如何在指令中检测当前状态 [英] How to detect current state within directive
本文介绍了如何在指令中检测当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用AngularUI的路由,我想执行ng-class="{active: current.state}"
,但是我不确定如何在这样的指令中准确检测当前状态.
I'm using AngularUI's routing and I'd like to do a ng-class="{active: current.state}"
but I'm unsure how to exactly detect the current state in a directive like this.
推荐答案
您还可以使用 ui-sref-active 指令:
<ul>
<li ui-sref-active="active" class="item">
<a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a>
</li>
<!-- ... -->
</ul>
或过滤器:
"stateName" | isState
& "stateName" | includedByState
Or filters:
"stateName" | isState
& "stateName" | includedByState
这篇关于如何在指令中检测当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文