Directive

wrAutofocus

Moves DOM focus to the host on init. Bind a boolean to focus reactively whenever the expression becomes truthy.

Import

import { WrButton } from 'ngwr/button';
import { WrAutofocus } from 'ngwr/directives';
import { WrInput } from 'ngwr/input';

Usage

<input wrAutofocus placeholder="Focused on init" />
<input [wrAutofocus]="shouldFocus()" />
Focus input

API

NameDescriptionTypeDefault
[wrAutofocus]Focus host on init, or whenever the bound expression becomes truthy.boolean (default true)