如何检测指令中的当前状态 [英] How to detect current state within directive

查看:31
本文介绍了如何检测指令中的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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 指令:

Also you can use ui-sref-active directive:

<ul>
  <li ui-sref-active="active" class="item">
    <a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a>
  </li>
  <!-- ... -->
</ul>

或过滤器:<代码>"stateName" |isState &<代码>"stateName" |containsByState

Or filters: "stateName" | isState & "stateName" | includedByState

这篇关于如何检测指令中的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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