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

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome