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

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

2 Answers 2

1

Using ngModel is the way to go here:

<input type="text" [(ngModel)]="heroInput"><p>{{heroInput}}</p>
Sign up to request clarification or add additional context in comments.

1 Comment

Agree I can use two way binding but then what's the use of reference variable?
1

try this

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

3 Comments

why this is required
you need an event to detect the change and update the UI but the event doesn't do anything
you need the event to detect the changes happened to the reference variable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.