I have a parent component and a child component, I need to pass the formGroup from my child component to my parent component.
I tried it this way:
Child component:
@Output() formGroup = new EventEmitter<Categoria>();
My constructor/create formGroup function:
constructor() {this.formGroup = createFormGroup()}
let createFormGroup = (dataItem?: CategoriaIcone) => {
if (dataItem) {
return new FormGroup({
'NomeImagem': new FormControl(dataItem.NomeImagem), //nome da imagem
'UrlImagemIcone': new FormControl(dataItem.UrlImagemIcone),
'Imagem': new FormControl(''),
'TypeImage': new FormControl('')
});
} else {
return new FormGroup({
'NomeImagem': new FormControl(''),
'UrlImagemIcone': new FormControl(''),
'Imagem': new FormControl(''),
'TypeImage': new FormControl('')
});
}
}
But I get an error in the constructor:
Type 'FormGroup' is missing the following properties from type 'EventEmitter': __isAsync, emit, subscribe, observers, and 17 more.