We can make use of Angular directives to make use of this functionality. AngularJS provides ng-init ( Initiate variable here ), ng-focus ( Trigger event when input got focus ),  ng-blur ( Trigger event when input lost focus )

Program Flow

  1. ng-init : Initiate focus variable as false
  2. ng-focus : Set true to the focus variable
  3. ng-blur : Set false to the focus variable
  4. Use focus variable to check focus

Markup

<h4>Focus and UnFocus below Text filed</h4>
<input ng-init="myFocusVar = false"  ng-focus="myFocusVar = true" ng-blur="myFocusVar = false"/><br>
<h4>Focus result</h4>
<div class="red" ng-bind="myFocusVar">
  This text color can be changed by class
</div>

0 comments:

Blogroll

Follow this blog by Email

Popular Posts