ฉันเขียนบริการส่งคืนสัญญา และในองค์ประกอบที่ฉันเรียกใช้บริการและตั้งค่าโมเดลเป็นข้อมูลที่ส่งคืนจากฟังก์ชันความสำเร็จของสัญญา โมเดลมีการเปลี่ยนแปลง แต่ GUI ไม่ได้รับการอัพเดต ฉันจะแก้ไขปัญหานี้ได้อย่างไร
Service :
getPage(pageNo) {
return new Promise ((resolve, reject) {
this.http.get(this.dataGetPageUrl+"/" + pageNo)
.map(response => response.json())
.subscribe(
blocks => {
resolve(blocks);
},
error => console.log(error)
);
})
}
Component:
Service.getPage(1).then(function(data) {
this.model = data;
}).catch(function(error) {
})