Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set input field placeholder from pipe

I would like to dynamically set <input type='text' placeholder=' {{ 'somestring' | getText }}'> placeholders using pipes. (this method does not work)

The pipe itself works perfectly fine e.g. <p>{{ myVariable | getText}}</p> will correctly render, as well as <p>{{ 'someString' | getText}}</p>

How does one use this to dynamically set placeholder strings?

like image 936
longbow Avatar asked Dec 19 '22 11:12

longbow


1 Answers

You can either use Matthias's suggestion or use double quotes for attribute/property/binding values. As a matter of fact, -always- use double quotes!

<input type="text" placeholder="{{ 'somestring' | getText }}">

or

<input type="text" [placeholder]="'somestring' | getText">
like image 113
Poul Kruijt Avatar answered Jan 08 '23 22:01

Poul Kruijt