ng-focus

Handler for focus event

Description

The ng-focus directive allows you to specify custom behavior when an element is focused.

Parameters


ng-focus

  • Type: Expression

  • Description: Expression to evaluate upon focus event. FocusEvent object is available as $event.

  • Example:

    <div ng-focus="$ctrl.greet($event)"></div>
    

Demo

<section ng-app>
  <input
    type="text"
    ng-focus="count = count + 1"
    ng-init="count = 0"
    placeholder="Click or tab into me"
  />
  Focused {{ count }} times
</section>
Focused {{ count }} times