I have the following view in my code:
<div data-ng-controller="HelloCtrl">
{{counties.selected}}
</div>
This piece of code will update the html successfully (when $scope.counties.selected
is set to a string:
$scope.$watch('counties.selected', function(newValue, oldValue) {
$scope.counties.selected = 'string';
});
However, the html doesn't update when $scope.counties.selected
is set to a variable as below. console.log(newValue);
show that newValue has the expected value set:
$scope.$watch('counties.selected', function(newValue, oldValue) {
console.log(newValue);
$scope.counties.selected = newValue;
});
Why doesn't newValue
propagate to the html?