How to implement $watch in angular
This article will explain in detail how to achieve $watch in angular. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Code
$scope.$watch ('custArea', function (newValue, oldValue) {angular.forEach (newValue, function (item, key) {if ($scope.custArea.indexOf ("000000") >-1) {/ / $scope.toastWarn ("all provinces and cities of Chinese mainland have been selected, other values are not selectable"); $scope.custArea = ["000000"];} else {});}, true) This is the end of the article on "how to achieve $watch in angular". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.