I am experiencing a challenge with the Event Emitter in my child component.
My goal is to pass a variable with EventEmitter to the parent component, but I would like to include a timeout function. Currently, the code looks like this:
CHILD:
export class AlertSuccess implements OnChanges {
@Input() success: SuccessCRM;
@Output() emitCollapse:EventEmitter<any> = new EventEmitter();
private info_ico: string = require('../../public/images/iconInfoTip.png');
public state: boolean = false;
constructor() {}
collapseAlert () {
let alert = document.getElementById('success');
setTimeout(function() {
console.log("BEFORE EMITTED STATE!!!!!: ", this.state );
console.log(this.emitCollapse);
this.emitCollapse.emit(this.state);
}, 500);
}
ngOnChanges(changes: SimpleChanges):void {
console.log("CHANGES: ", this.success);
this.collapseAlert();
}
}
In the parent component, everything is functioning as expected without the timeout function. I need guidance on how to integrate it within the timeout function!
Thank you in advance for your assistance!
Sincerely, Bosper