2017-11-10 14 views

답변

4

첫 번째 부분은 비동기 작업을 시작하고, 비동기 작업이 완료되기 전에 console.log 부분은 즉시 실행됩니다.

비동기 작업이 완료 될 때까지 this.data 참조를 연기해야합니다.

당신이 할 수있는 구독 핸들러 내부의 console.log을 넣어 :

this.postServices.getData().subscribe((res)=>{ 
    this.data = res; 
    console.log(this.data); 
})