0
這裏是我的服務角4 PouchDB沒有更新服務
export class LunchService {
private db: any;
lunches: any = [];
constructor(
private serverService: ServerService,
private configService: ConfigService,
) {
this.db = new PouchDB(configService.config.dbServer + '/' + configService.config.dbName);
this.db.find({
selector: { 'type': 'lunch' },
}).then((result) => {
// HERE
this.lunches = result.docs;
}).catch(function(err) {
console.log(err);
});
}
}
這裏是我的構成元素
export class ListingComponent {
lunches: any = [];
constructor(
private lunchService: LunchService
) {
// IS EMPTY WHEN SET IN SERVICE?
this.lunches = this.lunchService.lunches;
}
}
爲什麼在午餐服務的更改變量未在組件反映?控制器中的午餐參數不會被填充。
我猜它不是在變化檢測?但如何使這項工作?