AngularJS 数据绑定类型 [英] AngularJS data binding types

查看:28
本文介绍了AngularJS 数据绑定类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个已经回答了 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):

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.

这篇关于AngularJS 数据绑定类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆