@terminus/ui-autofocus
v2.0.1
Published
<h1>Autofocus</h1>
Downloads
5
Keywords
Readme
A directive that gives focus to an element on load.
Table of Contents
Installation
Use the ng add
command to quickly install all the needed dependencies:
ng add @terminus/ui-autofocus
Usage
The tsAutofocus
directive can be used on any element that has a .focus()
method. This includes
inputs, select menus, textarea, buttons, links, iframes and any element with a defined tabindex
above -1.
Add the directive to a focusable element:
<input type="text" tsAutofocus />
Binding
Passing in any value except false
, 'false'
, null
, or undefined
will enable the directive.
<!-- enabled -->
<input type="text" [tsAutofocus]="myProperty" />
<input type="text" [tsAutofocus]="true" />
<input type="text" tsAutofocus="" />
<!-- disabled -->
<input type="text" [tsAutofocus]="false" />
<input type="text" [tsAutofocus]="null" />