Ng-Blur-2

 

Example of Ng-Blur

 
 
 
<!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> .myBlur { background-color: lightskyblue; } .myFocus { border-left: 5px solid; } </style> </head> <body ng-app="app"> <div class="container"> <div ng-controller="LearnKode"> <h3>Ng-Blur</h3> <input ng-model="msg" class="form-control" type="text" ng-class="{ myFocus: focus, myBlur: blur }" ng-focus="focus=true;blur=false;" ng-blur="ngBlur()" /> <p>{{msg}}</p> </div> </div> <script> var app = angular.module("app", []); app.controller('LearnKode', ['$scope', '$timeout', function ($scope, $timeout) { $scope.msg = "LearnKode"; $scope.ngBlur = function () { $scope.clicked = false; $timeout(function () { if ($scope.clicked) { return; } $scope.blur = true; $scope.focus = false; $scope.msg = $scope.msg + ' *Ng-Blur* '; }) } }]); </script> </body> </html>
Output