angularjs - angular ng-class statement with multiple conditions
问题描述
I have to assign a class or an other to a field according two condition, one is about the position (it does not have to be the last one), the second is about a boolean parameter in my controller (my project is written using typescript and angular 1)
So i use: ng-class="(ctrl.parameter || !$last) ? 'class1' : 'class2'"
But it doesnt work.
Someone can help me
Thanks
解决方案
You can't use the ternary conditions in ng-class. it has to be like this
ng-class="{true: 'class1', false: 'class2'}[(ctrl.parameter || !$last)]"
推荐阅读
- javascript - 如何遍历这个 javascript 并获取 (id) 和 (brandName)
- express - 总是得到这个错误 'express' 不是内部或外部命令、可运行程序或批处理文件
- python-3.x - 熊猫时间戳
- html - 我如何通过内部文本选择 HTML 元素?
- node.js - Pact-js - 提供者/消费者测试存储库中缺失的文件
- php - 按特定索引扁平化 laravel 集合
- excel - INDEX、EQUIV 并选择了使用的范围
- symbolic-math - 从表达式中提取完整的参数和函数名称(仅限标准数学函数)MAPLE
- android - 白色状态栏上的白色通知图标不会变成黑色
- c# - MEF 在 VSIX 编辑器扩展中看不到其他项目中的依赖项