AngularJS数据绑定类型 [英] AngularJS data binding types
问题描述
我知道这是一个古老且可以回答100次的问题,但是最新版本使事情变得更加复杂,因此引起了我很多困惑. 我想知道在指令中为属性声明数据绑定的四种当前可用方法之间的区别是什么. 具体来说:
I know this is an old and 100 times-answered question, but things are getting more complex with the latest releases, thus causing me a lot of confusion. I'd like to know what is the difference between the four currently available ways to declare a data binding for an attribute in a directive. Specifically:
-
@
文本绑定 -
=
双向绑定 -
&
方法绑定(尽管有人称它为单向绑定) -
<
单向绑定
@
Text binding=
Two-way binding&
Method binding (although some call it one-way binding)<
One-way binding
我对最后两个之间的差异特别感兴趣,因为它们似乎具有重叠的功能,而且我真的无法分辨出两者之间的差异和优势.
I'm interested in particular in the difference between the last two, given that they seem to have overlapping functionalities and I really can't tell the difference and the advantages of one against the other.
推荐答案
以下是有关隔离范围的新单向绑定的一些信息.
Here is some information on the new one-way binding for isolate scope.
从GitHub: 1
From GitHub:1
feat($ compile):
向隔离范围定义添加单向绑定 此更改使开发人员可以绑定隔离范围/控制器属性 使用
<
绑定到表达式的方式是,如果 表达式更改,范围/控制器属性被更新,但 相反.
feat($compile):
add one-way binding to the isolate scope definition This change allows the developer to bind an isolate scope / controller property to an expression, using a
<
binding, in such a way that if the value of the expression changes, the scope/controller property is updated but not the converse.
该绑定实现为单个简单的手表,它还可以提供 相对于双向绑定的性能优势.
The binding is implemented as a single simple watch, which can also provide performance benefits over two way bindings.
- Closes #13928
- Closes #13854
- Closes #12835
- Closes #13900
这篇关于AngularJS数据绑定类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!