我想去除一个巨大角度应用程序的摘要。
我有很多来自http电话的更新,我想避免每次触发一次摘要,但每XXX最多一次。
例如,使用以下代码:
<div ng-app="myApp">
<div ng-controller="Ctrl as ctrl">
counter value : {{ctrl.counter}} - Should be 100 at the end of the process <br>
Digests count : <span id="digest-counter"></span> - Should be as low as possible
</div>
</div>
let digestsCounter = 0;
angular.module('myApp', []);
angular.module('myApp').controller('Ctrl', ($log, $timeout, $rootScope) => {
$rootScope.$watch(() => {
digestsCounter += 1;
document.getElementById('digest-counter').innerHTML = digestsCounter;
});
this.counter = 0;
for(let i = 0 ; i < 100 ; ++i) {
$timeout(() => {this.counter += 1}, 10 * i);
}
return this;
});
counter value : 100 - Should be 100 at the end of the process
Digests count : 202 - Should be as low as possible
如何去除摘要以避免202摘要?
这是一个fiddle,上面的代码说明了我的问题。