Auto focus
IMPORT MODULE

Allows to focus HTML-element right after its appearance, By default, it will take effect for input and textarea with [autofocus="autofocus"].

Examples

Basic Usage

Simplest of usage.

expand codeexpand code
import { Component } from '@angular/core';

@Component({
  selector: 'components-auto-focus-simple',
  template: `
    <button nz-button (click)="showInput = !showInput">Toggle Input</button>
    <div *ngIf="showInput" class="mt-md">
      <input nz-input auto-focus />
    </div>
  `,
})
export class ComponentsAutoFocusSimpleComponent {
  showInput = false;
}

API

auto-focus

PropertyDescriptionTypeDefault
[enabled]Whether enabled of auto focusbooleantrue
[delay]Delay of the focus (unit: ms)number300