1.

What is a template reference variable and how would you use it in Angular 6?

Answer»

Template reference variables are basically used to create a reference to the input element that can be used later on in any template. It is also called the hashtag syntax because it uses a hashtag to create a reference to an element in a template.

Example

<input #mobile placeholder="mobile number">
Here a reference has been CREATED to get the value of the input like:
//mobile is the input element
<button (click)="callmobile(mobile.value)">Call</button>
The above example is a foolproof method to avoid USING the ngModel or some TYPE of data binding by a simple form not requiring MUCH VALIDATION.



Discussion

No Comment Found