0

I have a directive in a directive. In the deepest directive I have this:

directive B:

scope.onChange = function () {
    scope.ngModel = scope.selectedItem.Id;

    $timeout(function () {
        scope.changed();
    }, 0);
}

In the directive on top of that directive I have this:

Directive A:

scope.onChange = function () {
    console.log(scope.ngModel);

    scope.changed();
}

The thing is, when I omit the timeout call in directive B, the console logs the 'old' value, but when I use the timeout call, everything works as expected. So my question is, why do I need to use the timeout here?

3

0

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.