i'm having issues using $scope.$watch in es6 project. watch fires once , never again.
here's code:
export class somecontroller { constructor($log, $scope) { 'nginject' this.watched = 1; $scope.$watch('watched',(nv,ov)=>{ $log(nv); //only fires once }); } othermethods(){}... }
specifically using generator: https://github.com/swiip/generator-gulp-angular
you try this:
$scope.$watch(() => this.watched, function (nv, ov) { console.log(nv); });
as explained more here.
here fiddle demo.
and also, event fires on $digest
cycles on :
dom events (user changing value of input field, clicking on button invoke javascript function , on)
xhr responses firing callbacks
browser's location changes
timers (settimout, setinterval) firing callbacks
or if call explicitly.
Comments
Post a Comment