ng-hide/ng-show 中是否可以使用复杂的表达式? [英] Are complex expressions possible in ng-hide / ng-show?
本文介绍了ng-hide/ng-show 中是否可以使用复杂的表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样做:
ng-hide="!globals.isAdmin && mapping.is_default"
但表达式的计算结果总是false
.
but the expression evaluates always to false
.
我不想在 $scope
上定义特殊函数.
I do not want to define special function on $scope
.
推荐答案
如果您需要运行任意 JavaScript 代码,请使用控制器方法,或者您可以定义返回 true 或 false 的过滤器.
Use a controller method if you need to run arbitrary JavaScript code, or you could define a filter that returned true or false.
我刚刚测试过(应该先完成),并且像 ng-show="!a && b"
之类的东西按预期工作.
I just tested (should have done that first), and something like ng-show="!a && b"
worked as expected.
这篇关于ng-hide/ng-show 中是否可以使用复杂的表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文