AngularJS ng-focus expression is evaluated when an element (window, input, select, textarea, a) gets focus.
<style> .focusClass {background-color: yellow;} </style> <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> focus={{focus}} </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>