In one of my components, I have a child component named slide1.component.ts
import { Component, Input, OnInit, EventEmitter, Output } from '@angular/core';
@Component({
selector: 'app-slide1',
templateUrl: './slide1.component.html',
styleUrls: ['./slide1.component.css'],
})
export class Slide1Component implements OnInit {
@Input() select_option: string;
@Output('answer') answer: EventEmitter<{
Res: any;
Ans: any;
}> = new EventEmitter();
constructor() {}
ngOnInit() {}
callchild() {
var res = this.answer.emit({ Res: '', Ans: '' });
console.log(res.length);
console.log('child ');
}
}
res.length
I am facing an issue where I get the error message
Property 'length' does not exist on type 'void'
, even though the method in the parent component returns an array. The function works fine in the parent component but not when called from the child component.
Working Link : https://stackblitz.com/edit/angular-ivy-gcgxgh?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fslide1%2Fslide1.component.ts