0
I have a parent component and a child component, I need to pass the formgroup of the child component to the parent component, I tried it that way:
Child element:
@Output() formGroup = new EventEmitter<Categoria>();
In the constructor I make an instance of that form group:
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 in the constructor:
Type 'Formgroup' is Missing the following properties from type 'Eventemitter': __isAsync, Emit, subscribe, Observers, and 17 more.
You created it as an eventEmitter and then re-assigned it to a formgroup, so the mistake.
– Eduardo Vargas