从管道设置输入字段占位符
Set input field placeholder from pipe
我想使用管道动态设置 <input type='text' placeholder=' {{ 'somestring' | getText }}'>
占位符。 (此方法无效)
管道本身工作得很好,例如
<p>{{ myVariable | getText}}</p>
将正确呈现,以及 <p>{{ 'someString' | getText}}</p>
如何使用它来动态设置占位符字符串?
您可以使用 Matthias 的建议或对 attribute/property/binding 值使用双引号。事实上,-总是-使用双引号!
<input type="text" placeholder="{{ 'somestring' | getText }}">
或
<input type="text" [placeholder]="'somestring' | getText">
我想使用管道动态设置 <input type='text' placeholder=' {{ 'somestring' | getText }}'>
占位符。 (此方法无效)
管道本身工作得很好,例如
<p>{{ myVariable | getText}}</p>
将正确呈现,以及 <p>{{ 'someString' | getText}}</p>
如何使用它来动态设置占位符字符串?
您可以使用 Matthias 的建议或对 attribute/property/binding 值使用双引号。事实上,-总是-使用双引号!
<input type="text" placeholder="{{ 'somestring' | getText }}">
或
<input type="text" [placeholder]="'somestring' | getText">