Sourabh Jain 543
Sourabh Jain 543

Reputation: 208

reference variable in angular2 is not working as expected

       <input type='text' #heroInput><p>{{heroInput.value}}</p>

Here the heroInput.value is not getting me the value inside text.

Upvotes: 0

Views: 120

Answers (2)

Arun Kumaresh
Arun Kumaresh

Reputation: 6311

try this

<input type='text' #heroInput (keyup)="0"><p>{{heroInput.value}}</p>

Upvotes: 1

Carsten
Carsten

Reputation: 4208

Using ngModel is the way to go here:

<input type="text" [(ngModel)]="heroInput"><p>{{heroInput}}</p>

Upvotes: 1

Related Questions