Hi
I have below HTML and i want the cursor should be at first column by default.
Sign In
User Name
Password
Thanks
Jayraj ChhayaPosted Jun 10, 2024, 1:10 PM
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:
ViewChilddecorator to get a reference to the input element:ngAfterViewInitlifecycle hook, set the focus on the input element:Rajendra TaradalePosted Jun 10, 2024, 7:02 AM
You can use autofocus html attribute or you create custom angular directive this.elementRef.nativeElement.focus() something like.