× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Use scope.$watch only in places where you really need it

Stepan Suvorov
May 30, 2015
<p>When you need to watch only specific event field chnage like keypress/keydown it's better to use native AngularJS directives:</p> <pre><code class="language-html">&lt;input ng-keypress="autocomplete()" ng-model="name"&gt;</code></pre> <p>instead of wating the model:</p> <pre><code class="language-javascript">$scope.$watch('name', function(){ $scope.autocomplete(); });</code></pre> <p> </p>
comments powered by Disqus