1
나는 다음과 같이 이벤트 이미 터가있는 구성 요소가 다음 loadStuff
방법은 Promise<any>
반환Angular2 "출력"콜백
<my-component (onLoadRequired)="loadStuff()" />
: 같은
@Output() onLoadRequired: EventEmitter<any> = new EventEmitter<any>();
이 사용되는 것을.
loadStuff
약속이 언제 해결되었는지 알고 싶으시면 my-component
이 필요합니다. 어떻게이 일을 성취 할 수 있습니까? 당신이 loadStuff()
돌려 Promise
을하면
대체 방법? HTML에서 논리가 부족한 부분을 원했고, 이상적으로는 하위 구성 요소 자체 내에서 처리하는 것이 가장 이상적이었습니다. – David
'loadStuff' 메소드를''와'loadStuff(). then (...)'에 전달할 수 있습니다. 당신은'loadStuff()'의'this'가 부모 클래스에서'loadStuff =() => this.doSomething()'또는'loadStuff = this.doSomething.bind (this)'처럼 reatained되도록주의해야합니다. –
'loadStuff 메소드를 전달할 수 있습니다'부분에 대해 궁금합니다. 뭔가 : @Input() loadMethod : Function;'? – David