import { Directive, ElementRef, afterNextRender, inject } from '@angular/core'; /** Focuses and selects its input when it renders, for inline editors that appear on demand. */ @Directive({ selector: 'input[appAutofocus]' }) export class AutofocusDirective { constructor() { const element = inject>(ElementRef).nativeElement; afterNextRender(() => { element.focus(); element.select(); }); } }