Sunday 27 December 2020

Focus() for Angular form control

 <form class="form-horizontal fonts" autocomplete="off" action="" ngSubmit)="onSubmit()">

<div class="form-group">

<label class="control-label" for="prmCorrSelect">Correlation</label>

<select id="prmCorrSelect" #drop class="form-control input-types fonts" name="prmCorrSelect">

   <option *ngFor="let data of correlationList" [value]="data.Id">{{data.Correlation}} 

   </option>

</select>


</form>



import { Component, ViewChild, ElementRef } from '@angular/core';


@Component({

  selector: 'my-app',

  templateUrl: './app.component.html',

  styleUrls: ['./app.component.scss']

})

export class AppComponent {


  @ViewChild("name") nameField: ElementRef;

  editName() {

    this.nameField.nativeElement.focus();

  }

}

No comments:

Post a Comment

Baisic Useful Git Commands

  Pushing a fresh repository Create a fresh repository(Any cloud repository). Open terminal (for mac ) and command (windows) and type the be...