简体   繁体   English

观看AngularJS

[英]Watch in AngularJS

I have created a jsFiddle with my code: http://jsfiddle.net/3qxKK/ . 我用我的代码创建了一个jsFiddle: http//jsfiddle.net/3qxKK/
Why the watch is never called when I changed an input value? 为什么在更改输入值时从不调用手表?

Maybe because "results" is not an object (but I put the parameter "true"): 也许是因为“结果”不是一个对象(但我把参数设置为“true”):

$scope.results = [];
angular.forEach($scope.services, function(service) {
    $scope.results[service.id] = '';
});

Besides, "results" in the template is always displayed as "[]". 此外,模板中的“结果”始终显示为“[]”。
It's strange because the value next the input is refreshed... 这很奇怪,因为输入的下一个值会被刷新......

Thanks in advance. 提前致谢。

How about changing it to an object ( DEMO )? 如何将其更改为对象( DEMO )?

$scope.results = {};

You've used an array. 你使用过数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM