如何根据模型的字符数有条件地应用类?
E.g:
$scope.sample = 555;
<span ng-class="{ 'char3': sample.length == 3 }">{{ sample }}</span>
答案 0 :(得分:1)
您可以将示例转换为字符串并检查其长度:
<span ng-class="{ char3: (sample + '').length == 3 }">{{ sample }}</span>
答案 1 :(得分:0)
<span ng-class="(sample.length === 3) ? 'three':'notthree'">{{ sample }}</span>