AngularJS ng-focus example

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

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

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


Click here to write/view comments