Q:

$setValidity not updating $valid flag in real-time

I'm using a custom form input validator implemented using a directive.  In the directive, the validation event is bound to the input's blur event. So on blur, it sets the validity of the model using $setValidity.  However, the $valid state is not updated until the model's value is modified again.  In other words, the $valid state always lags one state behind.
More specifically, I'm using the Angular Stripe helper library made available by backlift.com.  Here's the code block I'm referring to: Line 613 here.
On view, I have div blocks as such:
<div class="field-box error" ng-show="myForm.field.$dirty && myForm.field.$invalid">
    <div class="alert-msg"><i class="icon-remove-sign"></i> Some friendly message</div>
</div>

Any idea why $valid/$invalid properties are not updated as soon as the on-blur event is executed? FYI, the _validate method does its job correctly and $setValidity() is called with the correct values when expected.
Thanks in advance.

A:

scope.$digest will solve your problem. Whenever you integrate a non-Angular plugin in directive, make sure to do scope.$digest to keep scope updated.

