0
我有一個複選框列表,我能夠獲得選定的值,但問題是一旦我關閉並再次打開模型,我需要選中複選框之前選擇的值到目前爲止我能夠打印在複選框列表的標籤旁邊。有誰能告訴我如何做到這一點?如何在離子複選框中獲取默認選中的值
getSelect(isChecked, value) {
if (isChecked === true) {
this.ValArray.push(value);
} else {
this.ValArray.splice(this.multiValArray.indexOf(value), 1);
}
}
<ion-card *ngIf="filt.fieldType === 'Select'">
<ion-label padding-left>
{{filt.label}} {{filterCriteria.filter[filt.name]}}
</ion-label>
<ion-item *ngFor="let val of filt.value.Val | slice:0:showMore; let i=index" class="optional-filter-container">
<ion-label>{{val.label}}</ion-label>
<ion-checkbox color="theme-primary" [(ngModel)]="checked[i]" (ngModelChange)="getSelect(checked[i], val.value); filterCriteria.filter[filt.name] = ValArray;"></ion-checkbox>
</ion-item>
<button class="showmore-button" ion-button color="theme-primary" clear text-center *ngIf="showMore < filt.value.Val.length" (click)="showMore = showMore + filt.value.Val.length">
Show more</button>
</ion-card>