如何预填充Ionic 2离子输入区域?

Jas*_*son 2 typescript ionic-framework ionic2 angular

如何预填充Ionic 2离子输入区域?

我尝试过以下但是这个领域仍然空白.

<ion-input type="text" [(ngModel)]="product.content" name="content" value="123" required></ion-input>
Run Code Online (Sandbox Code Playgroud)

Sam*_*ath 5

你可以这样做,如下所示.

Working Plunk就在这里.

.TS

  product:any= {};
  constructor(public navController: NavController) {

    this.product.content='123';

  }
Run Code Online (Sandbox Code Playgroud)

注意:请勿使用any.始终使用type同TS.我刚刚在这里展示了简单的演示

html的

<ion-input type="text" [(ngModel)]="product.content" name="content"  
     required></ion-input>
Run Code Online (Sandbox Code Playgroud)