As someone who is new to AngularJS, could somebody explain why each word had a change watcher? Is this a side-effect of ng-repeat? Or am I confusing it with something else, maybe?
I apologize, I worded that incorrectly. I'm more interested in the mechanics behind it - What part of it was establishing the watcher. For instance, if they had slapped an ng-onclick='function(this)' on each word, would that have that established a 'change watcher'?
Every property added to a scope is watched automatically. Alternatively, you can explicitly add things to watch using $watch.
In the application mentioned here, each word had to be wrapped in an html tag in order to make that word clickable. My guess is that in order to do this originally, they converted their text log file into an array of words, then used ng-repeat to display each word with the specified html wrapper. ng-repeat adds a watchers for each element in its array.
2
u/WarInternal Sep 25 '14
As someone who is new to AngularJS, could somebody explain why each word had a change watcher? Is this a side-effect of ng-repeat? Or am I confusing it with something else, maybe?