Skip to content
Advertisement

AngularJS – Blur + Changed?

What is the easiest way to combine ng-changed and ng-blur?

I’ve found this post: How to let ng-model not update immediately?

However, this does no longer work in angluar 1.2+ Is there any way to achieve the same behavior?

I guess I have to store a copy of the old value myself and compare the new value to that on blur if I try to do the same, or is there any easier way ?

Advertisement

Answer

This does what I want. It stores the value on focus, and compares it to the new value on blur, if changed, it triggers the expression in the attribute.

JavaScript

usage:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement