How to get the value of a Textview?


Hi, I have a TextView where the user can type a message.

I need to get the value of the Textview while the user is typing.

I didn’t found clear docs about a simple thing like this.

Somebody have an idea about it?


// HTML: 
<Textview textWrap="true" (textChanged)="onChange($event);"></Textview>

  private onChange(event: any): void {
        this.inputValue = event.value;


@ParVis please take a look at the two-way Data Binding article in the official NativeScript Angular docs -


HI @Pete.K .

Do you have any idea on how to initialize the model “this.model”?

Some example on how to generate that reference to the model.



Hey @ParVis As @Pete.K suggested, You have to look at two-way Data Binding. This is what you want exactly.

This is how two-way Data Binding works :slight_smile: -

<Textview textWrap="true" [(ngModel)]="chat.text"></Textview>

<Label class="m-15 h2 text-left" text="This is how two-way Data Binding works" [(ngModel)]="chat.text" textWrap="true"></Label>


@ParVis, if you want to track for example the length of the text in the text view white the user is typing you can do it with ngModelChange

<TextView name="myTextView" [(ngModel)]="myTextView" (ngModelChange)="onMyTextViewChange($event)" text=""></TextView>


Thanks to all. Finally I resolved it on this way:


<Textview textWrap="true" (textChange)="onTextChange($event)" maxLength="{{maxChars}}"  hint="Your message here." returnKeyType="send"></Textview>


onTextChange(args) {

	this.message = args.object["text"];

	this.charsRemaining = this.maxChars - args.object["text"].length;