我有一个复选框列表,我能够获得选定的值,但问题是,一旦我关闭并再次打开模型,我需要复选框被选中与以前选定的值到目前为止,我能够打印它靠近标签的复选框list.Could有人建议我怎么做?
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>
发布于 2016-11-30 15:33:51
向ion-checkbox添加另一个属性,即
[checked]="displayValue" 如果'displayValue‘是真的,它会将复选框设置为选中。
在本例中,“displayValue”将是一个数组,其中包含每个迭代复选框的true或false值。
请尝试一次,并分享您的问题或反馈
https://stackoverflow.com/questions/40880420
复制相似问题