import { Component } from '@angular/core';
import { WrButton } from 'ngwr/button';
import { WrAutofocus } from 'ngwr/directives';
import { WrInput } from 'ngwr/input';
@Component({ imports: [WrButton, WrAutofocus, WrInput] })
export class MyComponent {}wrAutofocus
Focus an element on init, or each time a binding turns true.
Installation
Import the class, and @use the entry point in your global styles: without it the component renders unstyled.
Usage
Setting the binding back to false does not blur the element.
<input wrAutofocus placeholder="Focused on init" />
<input [wrAutofocus]="shouldFocus()" />API
| Name | Description | Type | Default |
|---|---|---|---|
[wrAutofocus] | Focus the host on init, or when the binding turns true. | boolean | true |