Reputation: 1124
I'm trying to pass a callback as a function parameter.
For example:
public abc1(doc:any){
console.log('abc1');
}
public abc2(model:any){
console.log('abcd2');
}
xyz.load(id.replace('/', ''), abc1, abc2);
Here abc1
and abc2
my callback functions and I'm trying to pass these functions in xyz.load
as 2 and 3 arg.
All are in the same component.
Upvotes: 1
Views: 6404
Reputation: 23506
You could define the load method like so:
load(id: string, callback1: (doc: any) => void, callback2: (model: any) => void) {
// do your stuff here
callback1(theDocument);
callback2(theModel);
}
And call it like this:
xyz.load(id.replace('/', ''), abc1, abc2);
Upvotes: 3