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

51 lines
1.2 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;
public res=[];
constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit(){
this._helpContentService.getDataProviders().subscribe(
res => {
this.res = res;
console.log(res);
});
}
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 + ')';
}
}