Multiple input ...How should I get value?


#1
<p *ngFor="let item2 of result let i = index" >
     <input [(ngModel)]=relayingId><button (click)="result">click</button>
</p>

have code like above and I have many input element according to array of result.
user should input only one of inputs then click button

but problem is that when I type something on input value , it applied to the others input like pic below


#2

because you are binding everything to a single object… you shouldn’t use *ngFor with inputs


#3

oh…but I should use for loop and each of loop should have input…
is there any other way to do so?


#4

but why do you want to use loop with inputs? this is some hell bad design in most of the cases


#5

I solved it by giving a input class name class="{{i}}"

on .ts

var input=(document.getElementsByClassName(i)[0]).value;
console.log(input);