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;
}
}
为什么在午餐服务的更改变量未在组件反映?控制器中的午餐参数不会被填充。
我猜它不是在变化检测?但如何使这项工作?