如何添加具有条件和对象属性的NG类

How to add NG-class with condition and an object property

本文关键字:对象 属性 NG 有条件 何添加 添加      更新时间:2023-09-26

我正在努力让这段代码正常工作。我希望结果是class="projectproject.select"

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

一个解决方案是:

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