I am trying to access a value of my input field. here is sample code
<div>
Test <input #test1 type="number" [value]='somevalue'/>
</div>
<div *ngIf='some-condition'>
Test <input #test2 type="number" [value]='somevalue'/>
</div>
<span (click)="testData(test1,test2)">test<span>
Angular Code
testData(testa,testD)
{
Console.log(testa);
Console.log(testD);
}
In above code, first div is working fine, but I am trying to do same thing in second div. It is giving me undefined value. I know something is missed.
if condition is false than it gives me undefined is fine, but when condition true is than also giving me undefined value.