Anytime a region variable changes, a digest cycle begins, which means that all observers are checked to see if something has changed. (actually 2 times for dirty checking). In the search field, you should strangle how many times you update the scope variable, otherwise the digest cycle will hit too hard. you can do it with bounce
<input type="text" name="variable1"
ng-model="variable1"
ng-model-options="{ debounce: 1000 }" />
Also, make sure that you do not create a new observer when changing the $ scope.variable1 variable. declare an observer once in your controller
Anytime:
{{variable}}
.
, 2000 , , , .
, :
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) {
if (element.data() && element.data().hasOwnProperty(scopeProperty)) {
angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) {
watchers.push(watcher);
});
}
});
angular.forEach(element.children(), function (childElement) {
f(angular.element(childElement));
});
};
f(root);
var watchersWithoutDuplicates = [];
angular.forEach(watchers, function(item) {
if(watchersWithoutDuplicates.indexOf(item) < 0) {
watchersWithoutDuplicates.push(item);
}
});
console.log(watchersWithoutDuplicates.length);
})();
, :
{{::variable}}
.
- , .
, , , , .
:
,
,