我进行了以下尝试,并且能够获取“所选复选框”的值,但无法获取已输入的“文本框”的值。所以我需要一些建议。
HTML文件
<ion-row class="service" *ngFor="let singleBarberService of allBarberServices">
<ion-col col-7 padding>
<ion-checkbox value="{{singleBarberService.service_id}}" (click)="clickSelectBox(singleBarberService)"></ion-checkbox> {{singleBarberService.service_name}} <br>
</ion-col>
<ion-col col-5>
<ion-input type="number" placeholder="Amount" min="0" step="0.01" name="amountservice" #amountservice required></ion-input>
</ion-col>
</ion-row>
注意:allBarberServices
包含JSON数组,它显示的APP页面具有以下屏幕截图。
TS文件:
clickSelectBox(itemKey){
const foundAt = this.selectedQuestions.indexOf(itemKey);
if (foundAt >= 0) {
this.selectedQuestions.splice(foundAt, 1);
} else {
this.selectedQuestions.push(itemKey);
}
console.log('Item Key: '+ itemKey.service_id);
console.log(this.amountservice.value); // fetch only the First Textbox Value
console.log(this.selectedQuestions); // This Displays all the Selected Checkbox Items
}