Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 3 how to use textarea ngModel and default value?

I am new in ionic and have a problem with textarea. This is my code:

<textarea  [(ngModel)]="userData.aboutme" name="" id="" cols="30" rows="20"  
    value="{{ about_me}}" style="width:100%; padding: 10px; margin-top: 3px;" > 
</textarea>

The problem is that the value is not showing inside textarea. It's show only if i remove the [(ngModel)]. I need help for this thanks a lot

like image 402
Amelie Perrin Avatar asked Nov 16 '17 13:11

Amelie Perrin


1 Answers

You need to use ion-textarea.

Note: This is just an example.Adjust it as you wish.

Working stackblitz

html

 <ion-item>
  <ion-textarea placeholder="Tap here" 
      [(ngModel)]="note" name="note" autocomplete="on" autocorrect="on"></ion-textarea>
 </ion-item>

.ts

  note: string = "My Default Text";
  constructor(public navCtrl: NavController) {

  }

Offical doc about ion-textarea

like image 62
Sampath Avatar answered Sep 30 '22 11:09

Sampath