Florent Hemmi
Florent Hemmi

Reputation: 105

Watch in AngularJS

I have created a jsFiddle with my code: 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"):

$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.

Upvotes: 0

Views: 110

Answers (1)

Marcel Gwerder
Marcel Gwerder

Reputation: 8520

How about changing it to an object (DEMO)?

$scope.results = {};

You've used an array.

Upvotes: 2

Related Questions