'Angular Event throws error in ViewChild decorator component
I have a Child Component child.component.ts with function
RenderData(test:false, event:Event) {
if(test) {
event.stopPropagation();
}
....
}
on another component where I am trying to import this function I have a child decorator
Test.Component.ts
@ViewChild('plainComponent')
plainComponent: PlainComponent;
// here I am trying to import RenderData();
openBox(dialog:MatDialogRef<any>) {
this.plainComponent.RenderData(false, Event);
}
Test.Component.html
<app-plain #plainComponent></app-plain>
<div>
<button mat-raised-button color="primary" (click)="done(dialog)">Run</button>
This EVENT there throws an error:
error TS2345: Argument of type '{ new (type: string, eventInitDict?: EventInit): Event; prototype: Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; readonly NONE: number; }' is not assignable to parameter of type 'Event'.
How do I solve this Event error?
Solution 1:[1]
You should intialise Event class
openBox(dialog:MatDialogRef<any>) {
this.plainComponent.RenderData(false, new Event('click');
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chellappan வ |
