【发布时间】:2017-04-27 15:18:32
【问题描述】:
我想从数据库中获取所有用户,为此我这样做:
// Get all users in the database.
getAllUsers() {
this.db.getAll('users').then((users) => {
console.log(users); //this logs all the users in the console.
}, (error) => {
console.log(error);
});
}
在我的组件中我这样做:
// input the result in the array.
const users: any = this.i.getAllUsers();
如果我尝试:
// Get all users in the database.
getAllUsers() {
this.db.getAll('users').then((users) => {
return users; //i don't get a return value...
}, (error) => {
console.log(error);
});
}
我没有得到任何返回值...
如果我这样做:
return this.db.getAll('users');
我得到了整个方法对象...
【问题讨论】:
标签: angular return components indexeddb