gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:59:38 25 4
gpt4 key购买 nike

我正在查看 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com