1
我無法讀取離子2 複選框值我嘗試下面的代碼離子2讀取複選框值
<div class="form-group">
<label ></label>
<div *ngFor="let mydata of activity" >
<label>
<input type="checkbox"
name="activity"
value="{{mydata.activity_id}}"
[checked]="activity.includes(mydata)"
(change)="changeSchedules(mydata)"
/>
{{mydata.activity_name}}
</label>
</div>
</div>
腳本文件
this.subscriptionForm = new FormGroup({
activity: new FormArray(this.subscription.schedules.map(schedule => new FormControl(schedule)), Validators.minLength(1))
});
changeSchedules(mydata: any) {
var currentScheduleControls: FormArray = this.subscriptionForm.get('activity') as FormArray;
var index = currentScheduleControls.value.indexOf(mydata);
if(index > -1)
{currentScheduleControls.removeAt(index) }
else
{
currentScheduleControls.push(new FormControl(mydata));
}
}
我搜索器那麼多的事情,但我沒有得到正確的解決方案 有人可以幫助搞清楚這
謝謝你爲我工作 – ganesh