42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
|
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 + ')';
|
||
|
}
|
||
|
}
|