Dejan.S Dejan.S - 1 year ago 141
AngularJS Question

store scope value, for it to be compared

I'm doing a

and sending the current value of a
into a
. My problem is that I want to save the previous input value and pass that into the blur function, because if value is same no action.

<input type="text" class="input__text" name="name" ng-model="name" ng-blur="bluryLines(name)">

$scope.bluryLines = function(oldValue, value) {
if (value !== '' | value !== oldValue) {
console.log('some action');
} else {
console.log('is empty');

Answer Source

Use ng-change to call your function and use ng-model-options="{ updateOn: 'blur' }"

<input type="text" class="input__text" name="name" ng-model="name" ng-change="bluryLines()" ng-model-options="{ updateOn: 'blur' }">


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download