[Fixed] Update table cell value on button click in Angular


I have a bootstrap table. Just before the table I have a button and a textbox. After input any number in the textbox and click on the generate button, I want to update the "Bill Amount" column of each row with the textbox value. How can I do this?

Amount : <input type="number" class="form-control" id="amount" name="amount" placeholder="Amount">
<button type="button" class="btn btn-primary" (click)="generateBill()">Generate</button>

<table class="table table-striped table-bordered">
        <th scope="col">#</th>
        <th scope="col"><input type="checkbox" [checked]="isAllCheckBoxChecked()" (change)="checkAllCheckBox($event)"></th>
        <th scope="col">Code</th>
        <th scope="col">Name</th>
        <th scope="col">Type</th>
        <th scope="col">Category</th>
        <th scope="col">Shop No</th>
        <th scope="col">Shop Name</th>                                        
        <th scope="col">Bill Amount</th>
    <tr *ngFor="let member of memberBillLists; let i = index">
        <td scope="row">{{ member.Id }}</td>
        <td scope="row"><input type="checkbox" value="{{member.Id}}" [(ngModel)]="memberBillLists[i].Checked"></td>
        <td><input type="number" class="form-control" [(ngModel)]="memberBillLists[i].BillAmount"></td>


You bind the input to a variable in your component file using two way binding. Then inside the generateBill() method you access memberBillLists array and update the bill amount with the amount you get from the two way binded value.

Leave a Reply

(*) Required, Your email will not be published