1

I am trying to access my angular scope and I keep getting the common issue :"$digest already in progress". I can't use $timeout because I have to be able to do this in the section of my html because I am using Kendo UI Grid and I have to initialize the grid in the html script section(I wish I could figure out how to do it all in my controller).

The code is pretty simple, so I don't know what else to try.

 ....
$(document).ready(function () {


    var scope = $('[ng-controller="NewIncidentController"]').scope();
    scope.$apply(function () {
        scope.submitfailure = true;          
    });

});

Thanks.

1
  • Instead of scope.$apply(function () {scope.submitfailure = true;});. Have you simply tried scope.submitfailure = true; ? Commented May 28, 2015 at 7:56

2 Answers 2

1

Try using scope.$applyAsync().

Sign up to request clarification or add additional context in comments.

1 Comment

@KishorSubedi not true, it provides enough info to pinpoint a problem. Although answer could be more verbose.
0

scope.$apply would call $digest internally which would cause the error you met since Angular allows only one cycle of digest at a time. $timeout service can execute your function in the next cycle of digest. For your situation, you can use scope.$evalAsync, which will execute the specified function in the on-going digest process, thus avoiding the exception.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.