Reputation: 226
I have a component that is a control I want to hold this actual control in a list of controls.
I am trying to pass the current component in my event emitter
@Output() passthings: EventEmitter,<{any, MyComponent}> new EventEmitter();
Then in my method
loadStuff(){
var component = this;
this.service.getStuff().subscribe(response =>{
this.passthings.emit({response, component}); <-----Errors here
}
the word response is underlined with the error "Argument of type '{response is not assignable to parameter of type '{any: any; MyComponent: any;}'
Upvotes: 1
Views: 1048
Reputation: 374
Try:
@Output() passthings: EventEmitter<any> = new EventEmitter<any>();
Or maybe you can define an interface...
interface myEmittedObject{
response: any;
control: any;
}
...and the EventEmitter like this
@Output() passthings: EventEmitter<myEmittedObject> = new EventEmitter<myEmittedObject>();
The interface could be nested to be more detailed:
interface myEmployeeData {
id: string;
name: string;
age: number;
active: boolean;
...etc.
}
interface myEmittedObject{
response: myEmployeeData ;
control: any;
}
Upvotes: 3