ng-blur the model's updated value is not avaiable in event
angularjs
Solution
Thanks for those suggestions. I actually managed to get this to work by adding 1 option to the updateOn property of ng-model-options. By adding in 'default' everything worked!
ng-model-options = "{updateOn: 'default blur}" was the trick.
<input type="text"
ng-model-options="{ updateOn: 'default blur' }"
ng-model="vm.myModel.amount"
ng-blur="vm.handleBlurEvent(vm.myModel.amount)" />
vm.handleBlurEvent = function(item)
{
//alert(item.amount); //new shows the NEW amount :-)
}
Problem
I am using the ng-model-options to prevent my text input's model from being updated until the focus is lost. That part all works. However, I need to handle the event after the text input loses focus and the model is updated. In that event I need access to the NEW model's updated value, not the old one. I am trying to use the ng-blur event, however, inside my handler the value is the old value, not the new value entered. Am I doing something wrong or is there a better way to get the newly committed model value after the text input loses focus? ``` <input type="text" ng-model-options="{ updateOn: 'blur', debounce:0 }" ng-model="vm.myModel.amount" ng-blur="vm.handleBlurEvent(vm.myModel.amount)" /> vm.handleBlurEvent = function(item) { //alert(item.amount); //Old amount - not new amount entered } ```