.html
<tr *ngFor="let item of itemList; let i=index">
<td><input type="checkbox" name="item"
[(ngModel)]="item.checked" ></td>
<td ></td>
<td ></td>
<td>
<a class="btn text-danger"><i class="fa fa-trash fa-lg"></i></a>
</td>
</tr>
.ts
ngOnInit(): void {
this.itemService.getItemList().then(res => this.itemList = res as Item[]);
this.formData = {
OrderItemID: null,
OrderID: this.data.OrderID,
ItemID: 0,
ItemName: '',
Quantity: 0
}
}
onSubmit(form: NgForm){
console.log(form.value);
}
So this component is part of a pop up dialog which is used to select one/multiple items from a checkbox in a table in a form. How do I return the multiple checked items into the main table (not in this component)? Currently it is returning a array of itemnames and whether they are checked or not. i.e. {Apple: undefined, Banana: undefined, Orange: true, Pear: true, …} How do I return the form data information (collection of items) such that it can populate the table in the main component?
Aucun commentaire:
Enregistrer un commentaire