I am currently utilizing [(ngModel)]
for two-way binding.
The structure in HTML is as follows -
<input
type="text"
[(ngModel)]="emailInput"
#toemail="ngModel"
[email]="true"
[style.color]="toemail.invalid && toemail.touched ? 'red' : ''"
/>
In the TypeScript file -
public emailInput: string;
In my component file, I can store the input value as a string in the variable emailInput
.
However, I would like to store the ngModel object in a variable within the component's TypeScript file. Even though I can access it in the HTML file using the reference variable toemail
, I want to access it in the component file.
Is there a way to achieve this?