angularjs - How to detect when angular is in its digest loop -


i have angularjs app shows message box when detects more number of rows have been returned in web service call. unfortunately, however, angular appears go digest loop when call service, , message box displayed 3 times.

i don't care angular needs internally, provided it's not way have coded function. however, don't want message box shown (nor web service called) 3 times. examining call stack each time function below called, can see call not originate application code.

how can detect state of loop can ignore calls after first one?

    function bindresults(expression) {         var maxrows = 100;         listdata.search(expression, maxrows).then(function (data) {             $scope.searchresults = data;             if (data.length == maxrows)             {                 var title = "search warning";                 var msg = "the maximum number of cases returned, try being more specific";                 var btns = [{ result: 'ok', label: 'ok', cssclass: 'btn-primary' }];                  $dialog.messagebox(title, msg, btns)                   .open();              }         });     }; 

you can check if $digest in progress checking $scope.$$phase.

if(!$scope.$$phase) {    //$digest or $apply } 

see more detailed answer here:

answer lee


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -