Angular 2 focus and blur for input elements

I wrote an input field in Angular 2 that has a placeholder value.

The input field must be empty in focus.

When blurred, the input field should revert to the placeholder value.

However, when blurring, nothing happens. Here is my input field:

<input type="text" 
       placeholder={{placeholderText}}
       onfocus="this.placeholder = ''" 
       (blur)="this.placeholder = placeholderText">

      

How can I change placeholder text on blur, in Angular 2?

+3


source to share


1 answer


There were several syntax problems



<input type="text" 
   placeholder={{placeholderText}}
   (focus)="placeholderText = ''" 
   (blur)="placeholderText = 'the placeholder'">

      

+3


source







All Articles