Ng-Blur-1

 

In this example of Ng-Blur, We have a textbox with ng-blur that will increment the count and set the isBlur variable to true. Based on the the on blur the textbox color will be changed. See the output

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style> .blur { background-color: skyblue; } </style> </head> <body ng-app="app"> <div ng-controller="LearnKode"> <div class="container"> <p>Name: <input class="form-control" ng-model="blur" type="text" ng-class="{blur:isBlur}" ng-focus="isBlur=false;blur='Ng-Blur False'" ng-blur="count1=count1+1;ngBlur();isBlur=true" /></p> <p>Age <input class="form-control" type="text" /></p> <p>Total count {{count1}}</p> </div> </div> <script> var app = angular.module("app", []); app.controller('LearnKode', ['$scope', function ($scope) { $scope.ngBlur = function () { $scope.isBlur = true; $scope.blur = "Ng-Blur True"; } }]); </script> </body> </html>
Output