Meaning of #var="ngModel"

Viewed 10039

I am creating login.component.html and during that time I create an input field then bind it to the email variable found in my login.component.ts. Originally I had written it as:

<input type="text" placeholder="Enter Email" id="email"
       [(ngModel)] = "email" name = "email" required #email="ngModel"/>

but continued to receive errors until I changed it to:

<input type="text" placeholder="Enter Email" id="email"
       [(ngModel)] = "email" name = "email" required #em="ngModel"/>

What exactly is going on at #em="ngModel" and why can I only use incredibly specific values?

2 Answers

I have the same issue few days back ,when I did R&D on it then i found that

 #var="ngModel" exports NgModel into a local variable called "var".

Through this we can check control states such as valid and dirty and touched

Related