AngularJS - Why watcher is removed? -


i new angularjs , follow long tutorial started. in 1 tutorial shows how remove watcher example below:

$scope.breakit = $scope.$watch('mydata.val',function(newval){     $scope.mydata.toolong = newval.length >3; })  <button ng-click="breakit()">break it</button> 

it works, don't understand why calling breakit function remove watcher?

$scope.$watch returns function deregisters watcher when called.


Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -