0

I am trying to update the front end by changing scope variable value after http response .

The scope variable is updated correctly but event happens after the alert() even though alert is placed after the statement where i am updating scope variable :

if (data.status === "Success") {
    $scope.close = null;// close updates dom after next statement which is not expected .

    alert(data.successmessage);
}
2
  • That is completely expected. Why would you expect differently? Commented Apr 26, 2019 at 4:20
  • @georgeawg $scope.close variable closes a popup . so in this case after http response alert happens and then the popup closes . Is it possible that after the dom is updated and then alert () just like the statement line number ? Commented Apr 26, 2019 at 4:22

1 Answer 1

2

One way to do it differently is to put the alert in a $timeout:

if (data.status === "Success") {
    $scope.close = null;// close updates dom after next statement which is not expected .

    $timeout(function() {
        alert(data.successmessage);
    });
}

That allows the browser to render the new DOM before doing the alert operation.

For more information, see

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

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.