AngularJS ng-focus Directive
Definition and Usage
ng-focus
directive tells AngularJS what to do when the HTML element gains focus.
AngularJS's ng-focus
The directive does not override the original onfocus event of the element, both of which will be executed.
Example
Execute the expression when the input field gains focus:
<input ng-focus="count = count + 1" ng-init="count=0" /> <h1>{{count}}</h1>
Syntax
<element ng-focus="expression</element>
Affected <a>
,<input>
,<select>
,<textarea>
and support for the window object.
Parameters
Parameters | Description |
---|---|
expression | The expression to be executed when the element gains focus. |