좋은 저녁 친구들angular2 http 해결 약속
나는 angular2에 빠지려고 노력 중이며, 계속 진행하지 못하는 문제가 있습니다.
서비스 :
getProject(id: number): any {
var url = this.ProjectsUrl + '/'+ id;
return this.http.get(url)
.toPromise()
.then(response => {
console.log(response.json().data as Project);
})
.catch(this.handleError);
}
요소 :
getProject(id:number){
this.projectService
.getProject(id)
.then(project => this.project = project);
}
ngOnInit()
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
this.getCustomers();
console.log('b4 getProj')
this.getProject(+params["id"]);
console.log('after getProj')
});
}
출력 :
b4 getProj
after getProj
Object { Project }
약속이 왜 풀리지 않는지 이해할 수 없습니까? 어떤 팁?
을 왜 뭔가가 해결되지 않습니다 생각하십니까? –