Skip to content

Instantly share code, notes, and snippets.

@mrtcmn
Last active October 27, 2017 19:21
Show Gist options
  • Save mrtcmn/a24cfa4cd854cd832645de1664df3f98 to your computer and use it in GitHub Desktop.
Save mrtcmn/a24cfa4cd854cd832645de1664df3f98 to your computer and use it in GitHub Desktop.
import { Component} from '@angular/core';
import { FormBuilder, FormGroup, FormsModule, FormArray } from '@angular/forms'; // Import required forms modules
@Component({
selector: 'form-creator-form'
templateUrl: './formCreatorForm.component.html'
})
export class formCreatorComponent implements {
_FormGroup: FormGroup; // We need to define FormGroup variables.
constructor( private fb: FormBuilder) { // Define FormBuilder to "fb" for direct access.
this._FormGroup = this.fb.group({
formName: '',
decs: '',
questions: this.fb.array([this.fb.group({
question: '',
questionType: '',
answers: this.fb.array([
this.fb.group({ value: ''})
])
})])
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment