Red
Red

Reputation: 115

How to dynamically append value to ion-textarea?

I'm new to ionic, angular. How can I dynamically append string values to an ion-textarea.

I know I can replace the value of the whole text area by using string interpolation like below. But how can I append values? I.e. add to the existing content.

            <ion-textarea 
            formControlName="message" 
            spellcheck="form" placeholder="write here...." 
            auto-grow 
            rows="2"
            value="{{appendedValue}}"
            >
            </ion-textarea>

Upvotes: 1

Views: 1763

Answers (1)

herman carrasco
herman carrasco

Reputation: 36

change value to ngModel, 2 way data binding

        <ion-textarea 
          formControlName="message" 
          spellcheck="form" placeholder="write here...." 
          auto-grow 
          rows="2"
          [(ngModel)]="appendedValue“
        >
        </ion-textarea>

or put value between [], to assign the value of the variable appendedValue.

        <ion-textarea 
          formControlName="message" 
          spellcheck="form" placeholder="write here...." 
          auto-grow 
          rows="2"
          [value]="appendedValue"
        >
        </ion-textarea>

Upvotes: 2

Related Questions