【问题标题】:Angular JS - to tag single class for multiple expressions in ng-classAngular JS - 为 ng-class 中的多个表达式标记单个类
【发布时间】:2014-05-24 03:04:06
【问题描述】:

我正在尝试找到在 ng-class 中为多个表达式标记单个类的语法:

<li class="data-ng-class: {'left': $even, 'first-left': (year==recentActiveYear && $index == 1) 'right': $odd, 'first-right': $index == 1, 'first-recentYear': year==recentActiveYear}" > 

当我使用上面的那个时,第一个左类没有得到应用。 请,任何人都可以帮助正确的语法。

谢谢。

【问题讨论】:

    标签: angularjs ng-class


    【解决方案1】:

    我建议试试这个:

    <li data-ng-class="{ 'left': $even, 'first-left': (year==recentActiveYear && $index == 1), 'right': $odd, 'first-right': $index == 1, 'first-recentYear': year==recentActiveYear }">
    

    您的代码的一个问题是ng-class 是它自己的属性,不应该放在类属性中。

    我最后看到的是'first-left''right' 之间存在语法错误。您在两者之间缺少,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-06
      • 1970-01-01
      • 2023-03-26
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      相关资源
      最近更新 更多