vignesh selvarathinam vignesh selvarathinam - 20 days ago 8
AngularJS Question

AngularJs: How to call the angularjs function by Pressing tab button after entering text in the text box?

I am wondering how to call the angularjs function by Pressing tab button?



var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {



});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"><br>

</div>





How to call the function using angularJs, after Pressing the firstName and click on tab button. since i am new to angularJs, i know ng-click,ng-change, but i got no idea about this.

please someone help me.

Thanks in advance

gyc gyc
Answer

You could use ngBlur.

However, it will run the function if you click outside of the input as well as tabbing out.

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
      
    $scope.tabbedout = function(val) {
      console.log("tabbedout: " + val);
    }
  
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName" ng-blur="tabbedout(firstName)"><br>
Last Name: <input type="text" ng-model="lastName" ng-blur="tabbedout(lastName)"><br>

</div>

Comments