AngularJS ng-blur example

AngularJS ng-blur expression is evaluated when an element (window, input, select, textarea, a) loses focus.

<style>
.blurClass {background-color: lightgray;}
</style>
<div ng-app="myApp" ng-controller='MyCtrl' ng-init="blur=false;">
  Click on input field and click somewhere else.
  <input type="text" ng-class="{blurClass: blur}" ng-blur="blur=true;" ng-focus="blur=false;"><br>
  blur={{blur}}
</div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
  var module = angular.module('myApp', []);
  module.controller('MyCtrl', function($scope) {});
</script>
refresh
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments