是否angularjs treates null作为$ scope.null? [英] Does angularjs treates null as $scope.null?
本文介绍了是否angularjs treates null作为$ scope.null?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
举例问题
<div ng-show="bar !== null">hello</div>
这是在范围评为
$scope.bar !== null
或者是因为这?
$scope.bar !== $scope.null
请注意,在最后一种情况下,$ scope.null将是不确定的和例子似乎工作的权利。
Note that in last case, $scope.null would be undefined and the example would seem to work right.
奖励:
如果巴= null,则发生这种情况。
if bar = null then this happens
// this does not work (shows hello)
<div ng-show="bar !== null">hello</div>
不给相同的结果
// this works ok (does not show hello)
<div ng-show="bar != null">hello</div>
为什么会发生呢?
why does that happen?
推荐答案
没有,角<一个href=\"https://github.com/angular/angular.js/blob/71fc3f4fa0cd12eff335d57efed7c033554749f4/src/ng/parse.js#L594\"相对=nofollow>识别在EX pressions一些JS原语和空
就是其中之一。
No, Angular recognizes some JS primitives in expressions, and null
is among them.
这篇关于是否angularjs treates null作为$ scope.null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文