juniorsuporte2011 free asked 4 years ago

How do I change the focus from one matInput to another matInput using typeScript,


Joel Junior

Konrad Stępień staff answered 4 years ago

Hi @juniorsuporte2011,

This is one solution:

<div class="md-form">
  <input mdbInput type="text" id="form1" class="form-control" (click)="focusInput.focus()">
  <label for="form1" class="">Example label</label>

<div class="md-form">
  <input #focusInput mdbInput type="text" id="form2" class="form-control">
  <label for="form2" class="">Example label</label>

You can also use @ViewChild property in your ts code.

Best, Konrad.

juniorsuporte2011 free commented 4 years ago

thank you very much

Joel Junior

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 8.2.0
  • Device: DeskTop
  • Browser: chrome
  • OS: windows 10
  • Provided sample code: No
  • Provided link: No