如何添加带有条件和对象属性的NG-class

时间:2015-06-28 17:43:17

标签: javascript angularjs

我正在尝试使此代码正常工作。我希望结果是class =“project project.select”

ng-class="{'project': $state.current.name == 'project.select', $state.current.name}"

1 个答案:

答案 0 :(得分:1)

一个解决方案是:

<elem ng-class="{'project': $state.current.name == 'project.select'}"
      class="{{$state.current.name}}"></elem>