[英]Can I use a custom built Angular component as a placeholder for an Input field
[英]How can I set input placeholder text in component file in Angular
我是Angular和Typescript的新手。 我在下面帶有placeholder
的輸入中,有沒有辦法從組件文件中更改placeholder
文本?
<input id="city" class="form-control" placeholder="City or Town">
您可以只綁定placeholder
屬性。 Stackblitz
<input id="city" class="form-control" [placeholder]="placeholder">
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
placeholder = 'Angular';
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.