angularjs是否作为$scope.null处理null?

前端之家收集整理的这篇文章主要介绍了angularjs是否作为$scope.null处理null?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_403_4@
问题的例子

<div ng-show="bar !== null">hello</div>

这是否在范围内评估为

$scope.bar !== null

还是这样?

$scope.bar !== $scope.null

请注意,在最后一种情况下,$scope.null将是未定义的,并且示例似乎正常工作.

奖金:

如果bar = null则会发生这种情况

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

为什么会这样?

@H_403_4@

解决方法

不,Angular recognizes表达式中有一些JS原语,而null就是其中之一. @H_403_4@ @H_403_4@

猜你在找的Angularjs相关文章