Hi
I have below HTML and i want the cursor should be at first column by default.
Code
Sign In
Email
-->
User Name
PasswordThanks

Rajendra TaradaleRank #1,289 · 1.3K reputationPosted Jun 10, 2024, 3:02 AM EDT
You can use autofocus html attribute or you create custom angular directive this.elementRef.nativeElement.focus() something like.
Jayraj ChhayaRank #304 · 8.2K reputationPosted Jun 10, 2024, 9:10 AM EDT
To set the cursor at the first column by default in Angular, you can use the
ViewChilddecorator along with theElementRefclass to access the input element and set the focus programmatically.Here's an example of how you can achieve this:
import { Component, ElementRef, ViewChild } from '@angular/core';ViewChilddecorator to get a reference to the input element:@ViewChild('usernameInput') usernameInput: ElementRef;ngAfterViewInitlifecycle hook, set the focus on the input element:ngAfterViewInit() { this.usernameInput.nativeElement.focus(); }