Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

AngularJS ng-focus Directive

AngularJS ng-focus Instruction

AngularJS Reference Manual AngularJS Reference Manual


AngularJS Examples

Execute an expression when the input field gains focus:

<

input

ng-focus=

"count = count + 1"

ng-init=

"count=0"

/

<

h1

{{count}}

<

/h1

Try it »


Definition and Usage

ng-focus The directive tells AngularJS the action to take when an HTML element gains focus.

ng-focus The directive does not override the element's native onfocus event. When the event is triggered,ng-focus both the expression and the native onfocus event will be executed.


Syntax

<

element

ng-focus=

"expression"

<

/element

, ,


Parameter value

Value Description
expression The expression to execute when the element gains focus.

AngularJS Reference Manual AngularJS Reference Manual