簡體   English   中英

如何在Angular的組件文件中設置輸入占位符文本

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM