0

Please developers in the house, I have a table in my angular Application that am populating with a data from database and a row which is an input text field that I need to fill from FrontEnd and binding the Input text field using ngModel to be send to the database. But I observed that if I have three record in the table and I try typing in a value in one of the Input field, the other two input fields automatically get filled with the data am filling in one Input text field which I think is as a result of ngModel. Please how can i bind it so that the input number type in one input field will not be filled in other fields. Below is my code: Thank you for your help.

 <tbody>
                                 <tr *ngFor = "let SelectItem of selectRequisition ; let i = index ">
                                <td style="width: 150px;">{{SelectItem.transactionDate |date}}</td>
                                   <td style="width: 150px;">{{SelectItem.description}} </td>
                                   <td style="width: 150px;"> {{SelectItem.remark}} </td>
                                   <td style="width: 150px;"><input type = "number" ngModel = "InputItem"></td>
                                 </tr>
                                </tbody>

1 Answer 1

1

I think the best approach for you will be to add a property to your model and bind it to your input. For example, with this model:

export interface MyItemModel { 
 transactionDate:number;    
 description:number;    
 remark:string; 
 SomeNumber:number; // <-- Add this property
}

You can bind the SomeNumber property to the input like this:

<input type="number" [(ngModel)]="SelectItem.SomeNumber">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.