AngularJS ng-focus Instruction
AngularJS Examples
Execute an expression when the input field gains focus:
<
input
ng-focus="count = count + 1"
ng-init=
"count=0"
/
<
h1
{{count}}
<
/h1Try 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