是否angularjs treates null作为$ scope.null?treates、angularjs、scope、null

由网友(深爱的另一个名字叫卑微)分享简介:举例问题hello这是在范围评为$scope.bar !== null或者是因为这?$scope.bar !== $scope.null请注意,在最后一种情况下,$ scope.null将是不确定的和例子似乎工作的权利。Note that in...

举例问题

<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?

推荐答案

没有,角识别在EX pressions一些JS原语和就是其中之一。

No, Angular recognizes some JS primitives in expressions, and null is among them.

阅读全文

相关推荐

最新文章