1
콜백을 함수 매개 변수로 전달하려고합니다. 예를 들어콜백을 함수로 전달하는 방법
:
여기abc1
및
abc2
내 콜백 함수와 내가
xyz.load
2와 3 인수에 이러한 기능을 전달하기 위해 노력하고있어
public abc1(doc:any){
console.log('abc1');
}
public abc2(model:any){
console.log('abcd2');
}
xyz.load(id.replace('/', ''), abc1, abc2);
. 모두 동일한 구성 요소에 있습니다.
load(id: string, callback1: (doc: any) => void, callback2: (model: any) => void) {
// do your stuff here
callback1(theDocument);
callback2(theModel);
}
을 그리고 다음과 같이 호출 :
(theDocument); 콜백 2 (theModel); 이리? 귀하의 경우에는 'abc1'과'abc2'가 –
입니다. 'theDocument'와'theModel'은 어디에서 왔는지 모르기 때문에 그냥 자리 표시 자입니다. – rinukkusu