user1650978 user1650978 - 3 months ago 18
Javascript Question

AngularJS - call function after text field completion

I have a text field as

<input type="text" class="form-control" id="inputID" name="inputName" ng-model="inputUserName" ng-required="true" autofocus="true"/>


Once I input the text value and say, press Tab, or move on to the next field, I want to call a function which basically takes the input value and sends it to my server API to perform a validity check. How can I achieve this?

Answer

use the ng-blur:

<input type="text" ng-blur="method()">

https://docs.angularjs.org/api/ng/directive/ngBlur

Comments