angularJS ng-model 输入类型号到 rootScope 未更新

2023-12-28

我的输入类型编号设置为

<input type="number" ng-model="inputModel"/>

Where inputModel is $rootScope.inputModel。每次我更改输入框时,该值都不会保留在$rootScope。是否可以将输入框绑定到$rootScope?我在这里缺少什么?
我基本上有另一个控制器来执行给定的计算$rootScope这些计算会根据输入框的值而变化。
非常感谢您的帮助

Thanks


See 这个问题 https://stackoverflow.com/questions/22216441/what-is-the-difference-between-scope-root-and-rootscope- 你可以使用$root范围上的属性和绑定将是

<input type="number" ng-model="$root.inputModel"/>

这将直接绑定到根范围,而不需要在控制器中显式分配它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

angularJS ng-model 输入类型号到 rootScope 未更新 的相关文章

随机推荐