import {Component, OnInit, Input} from '@angular/core'; import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms"; import { HelpContentService } from "../../services/help-content.service"; @Component({ selector: 'community-form', templateUrl: './community-form.component.html', }) export class CommunityFormComponent implements OnInit{ @Input('group') myForm: FormGroup; public errorMessage: string; constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService){} ngOnInit(): void {} public get form() { return this._fb.group({ _id : '', name : ['', Validators.required] }); } public reset() { this.myForm.patchValue({ name : '', _id : '' }); } handleError(message: string, error) { if(error == null) { this.reset(); } this.errorMessage = message + ' (Server responded: ' + error + ')'; } }