javascript - AngularJS 官方网站中理解双向数据绑定(bind)教程

标签 javascript angularjs

我正在查看 AngularJS 网站上解释双向数据绑定(bind)的官方教程。

https://docs.angularjs.org/tutorial/step_04

教程提到了这一点:

Angular creates a two way data-binding between the select element and the orderProp model. orderProp is then used as the input for the orderBy filter.

但是,当查看live demo时我只看到单向绑定(bind)。

任何人都可以解释一下该演示应该如何说明双向数据绑定(bind)吗?

最佳答案

教程有这样的解释(强调我的):

This is a good time to talk about two-way data-binding. Notice that when the app is loaded in the browser, "Newest" is selected in the drop down menu. This is because we set orderProp to 'age' in the controller. So the binding works in the direction from our model to the UI. Now if you select "Alphabetically" in the drop down menu, the model will be updated as well and the phones will be reordered. That is the data-binding doing its job in the opposite direction — from the UI to the model.

这就是双向绑定(bind)的演示。虽然不是很明显。

关于javascript - AngularJS 官方网站中理解双向数据绑定(bind)教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32350081/

相关文章:

javascript - 如何从附加的 html div 访问 css 类?

javascript - 在 selenium/appium 中,有一种方法可以在单击按钮等后检查/验证单击操作是否成功或不成功

javascript - Vue.js 和 vue-moment : "Failed to resolve filter: moment"

angularjs - 带有 AngularJS 的 KendoUI Treeview 取消选中复选框

javascript - 正则表达式中的括号未被替换

javascript - 如何将firebase返回的数据保存到变量

javascript - 将指令转换为 typescript 中的组件

angularjs - 使用 karma 运行 angularjs 单元测试时,如何在终端中查看 $log 调用?

AngularJS:动态创建元素

javascript - AngularJS - 在一个 html 标签中切换变量