Ashish
Ashish

Reputation: 14707

How to clear placeholder in angular on focus

How can I clean the value of variable on selecting the input box in angular 2 and angular material.

<div> <input type="text" placeholder="Search..." [value]="searchValue" [(ngModel)]="variable" > </div>

export class App { } }

Upvotes: 2

Views: 905

Answers (1)

Gosha_Fighten
Gosha_Fighten

Reputation: 3858

You can do this using the following CSS:

input:focus::-webkit-input-placeholder {
   color:transparent;
}

input:focus:-moz-placeholder { /* Firefox 18- */
   color:transparent; 
}

input:focus::-moz-placeholder {  /* Firefox 19+ */
   color:transparent; 
}

input:focus:-ms-input-placeholder {  
   color:transparent;
}

See the plunk.

Upvotes: 2

Related Questions