NG-秀与UnderscoreJS的工作_.isNull但VAL工作===空 [英] ng-show not working with UnderscoreJS's _.isNull but works with val === null
问题描述
我有与NG-显示指令的元素,当我使用UnderscoreJS辅助函数_.isNull它的工作同样是为使用标准===运算符。
I've got an element with an ng-show directive and when I use the UnderscoreJS helper function _.isNull it work the same was as using the standard === operator.
因此,这显示与newJobWorkPercentage内容为空。
So this displays the content with newJobWorkPercentage is null.
<div class="form-group" ng-show="newJobWorkPercentage === null">
... some content
</div>
但这并不
<div class="form-group" ng-show="_.isNull(newJobWorkPercentage)">
... some content
</div>
我可以只使用===我的应用程序,我只是好奇为什么助手无法正常工作。
I can just use the === in my app, I'm just intrigued why the helper doesn't work.
推荐答案
角前pressions只针对评估该视图的 $范围
。因此,要使用下划线在你看来,你需要把它添加到 $范围
变量控制器内的:
Angular expressions are only evaluated against the $scope
of that view. So to use underscore in your view you would need to add it to the $scope
variable inside your controller:
$scope._ = _;
现在你就可以使用里面的前pressions下划线功能。
Now you will be able to use the underscore functions inside expressions.
这篇关于NG-秀与UnderscoreJS的工作_.isNull但VAL工作===空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!