7
पर मौजूद नहीं है I इस लिंक http://plnkr.co/edit/yV94ZjypwBgHAlb0RLK2?p=preview से कोड लागू किया गया था लेकिन पुश और नियंत्रण त्रुटि प्राप्त हो रही थी।कोणीय 4: संपत्ति "पुश" और "नियंत्रण" प्रकार "AbstractControl"
यहां मैंने जो किया और यह नहीं पता कि इसमें क्या गलत है।
import { Component } from '@angular/core';
import { ViewController,Platform } from 'ionic-angular';
import { FormBuilder,FormGroup,Validators,FormControl,FormArray } from '@angular/forms';
@Component({
selector: 'filter-vendor',
templateUrl: 'filter-vendor.html'
})
export class FilterVendorPage {
questions = [{id:1,text:'Question 1', answers:[{id:1},{id:2}]},{id:2,text:'Question 2', answers:[{id:11},{id:22}]}]
surveyForm:FormGroup;
constructor(
private viewCtrl: ViewController,
private formBuilder:FormBuilder
){
this.surveyForm=this.formBuilder.group({
question:formBuilder.array([])
})
for(var i=0;i<this.questions.length;i++){
let question=formBuilder.group({
question_id:[this.questions[i].id,Validators.required],
answer_id:formBuilder.array([])
});
this.surveyForm.controls['questions'].push(question);
}
}
onChange(id, isChecked, index) {
const answers = <FormArray>this.surveyForm.controls.questions.controls[index].controls.answer_ids
if(isChecked) {
answers.push(new FormControl(id))
} else {
let idx = answers.controls.findIndex(x => x.value == id)
answers.removeAt(idx)
}
}
}
कृपया मुझे इस issue.Lot के धन्यवाद
एक बहुत का मेरे दिल के नीचे से धन्यवाद। तुमने मेरी जान बचाई। –
मुझे खोजने में त्रुटि मिल रही है इंडेक्स idx = answer.controls.findIndex (x => x.value == id) answer.removeAt (idx) मुझे नहीं पता कि इसमें क्या गलत है क्योंकि यह प्लंकर में ठीक काम करता है। –