AngularJS:与号码输入双向数据绑定 [英] AngularJS: Two-Way Data Binding with Number Inputs

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

问题描述

我想使用的角度进行数据绑定输入类型=数字元素,但我似乎无法弄清楚如何获得工作的结合。例如,当我更新任何价值,我希望绑定给它的值也进行更新。

I'm trying to use angular for data-binding input type="number" elements, but I can't seem to figure out how to get the binding working. For example, when I update any of the values, I expect the value binded to it to also update.

JSBin: http://jsbin.com/kiqivule/3/edit

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

一个几件事情:

您需要看的,以更新的轮胎属性更改为自行车属性。

You need to "watch" for changes to the "bikes" property in order to update the "tires" property.

下面是一个更新的JSBin展示了如何做到这一点:的http:// jsbin。 COM / kiqivule / 15 /编辑?HTML,JS,

Here's an updated JSBin showing how to do it: http://jsbin.com/kiqivule/15/edit?html,js,output

首先, $ watchGroup只能排在V1.3.0-beta.6 - 在脚本你使用V1.2.10

Firstly, $watchGroup only came in at v1.3.0-beta.6 - in your script you're using v1.2.10.

其次,所有在此处引用的jsbins被示出,当自行车属性正在更新的轮胎属性被更新。 这里的另一个jsbin 这表明这个有点更清晰。

Secondly, all the jsbins that are referenced here are showing that the tires property is being updated when the bikes property is being updated. Here's another jsbin which show this a bit more clearly.

所以,我还是不知道你追在这里?

So I'm still not sure what you're chasing here?

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

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