Monday, October 16, 2017

angularjs scope.$watch and expression with square brackets

I have found some legacy code in the product that I work on:

$scope.$watch("[timeRange]", function() {
  doStuff();
}, true);

timeRange is an object on the scope.

I don’t understand this syntax of watching something with square brackets round it. I have searched the web and the angularjs documentation and still can’t work it out. Can someone help explain what this construct means?

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/16/angularjs-scope-watch-and-expression-with-square-brackets/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment