AngularJS listens for array changes

When we use angualr's monitoring, we will monitor a certain value change of an array and write logic code according to business needs. However, when we use $scope.$watch("", function(){
}), we will find that it does not work. This is because $scope.$watch has three parameters. By default,
$scope.$watch(" ", function(){
}, false), just to monitor whether the address of the array changes, when we want to monitor a certain value of the array, we need to set the third parameter to true, as follows.

$scope.$watch("files",function(){

},true);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326487353&siteId=291194637