connect-admin/app/pages/community/community-edit-form.compone...

42 lines
1.0 KiB
TypeScript
Raw Normal View History

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-edit-form',
templateUrl: './community-edit-form.component.html',
})
export class CommunityEditFormComponent 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 + ')';
}
}