AngularJS 及其对美元变量的使用 [英] AngularJS and its use of Dollar Variables
问题描述
有谁知道在 angularJS 中使用美元方法和变量背后的原因是否是为了指示 angularJS 在消化过程中避免检查这些值?那么,如果 angular 遇到 $scope.$value
和 $scope.value
,那么它会避免检查前者,因为它的变量名中带有美元字符前缀?
Does anyone know if the reasoning behind the use of dollar methods and variables in angularJS is to instruct angularJS to avoid checking those values when a digestion is going on? So, if angular comes across $scope.$value
and $scope.value
, then it will avoid checking the former since it's prefixed with a dollar character in its variable name?
推荐答案
Angular 有几次会忽略以美元符号为前缀的变量:
There are a few times Angular ignores variables prefixed with the dollar sign:
- 在下面的 Schumli 的评论中,json 过滤器将不输出它们
当使用
{{ }}
指令时,angular 不会显示 nested$
变量.例如,这仅显示visible
属性.
- In Schumli's comment below, where json filters will not output them
When using the
{{ }}
directive, angular will not show nested$
variables. For example this only displays thevisible
property.
<div ng-init="n = { visible: 'foo', $ignore: 'bar' };">{{ n }}</div>
此外,在作用域对象上添加显式观察器时,对带有该对象前导美元符号的属性的更改不会触发观察器.请参阅这个更新的小提琴.
angular.equals()
忽略以 $ 为前缀的键
.
这篇关于AngularJS 及其对美元变量的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!