javascriptangularinputmaterial-designselectall

Angular Material Input Select All on Click?


Pretty straight-forward question. When I click on an input field I want to select-all the text so when I start typing it over-writes what was previously there. Anyone know how to do this?


Solution

  • Seems the following should work:

    <input matInput (click)="$event.target.select()">
    

    Example