我收到错误,并且使用angularfire for firebase也没有数据进入Angular和离子应用程序。
package.json:
"dependencies": {
"@angular/common": "5.0.3",
"@angular/compiler": "5.0.3",
"@angular/compiler-cli": "5.0.3",
"@angular/core": "5.0.3",
"@angular/forms": "5.0.3",
"@angular/http": "5.0.3",
"@angular/platform-browser": "5.0.3",
"@angular/platform-browser-dynamic": "5.0.3",
"@ionic-native/core": "4.4.0",
"@ionic-native/splash-screen": "4.4.0",
"@ionic-native/status-bar": "4.4.0",
"@ionic/pro": "1.0.16",
"@ionic/storage": "2.1.3",
"angularfire2": "^5.0.0-rc.1",
"firebase": "^4.4.0",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
firebase的服务:
constructor(public afDB: AngularFireDatabase) {
console.log('Hello FireBaseServicesProvider Provider');
}
getStockUserList(){
// let getData = this.afDB.list().
return this.afDB.list('stock/').valueChanges();
// this.afDB.list('stock/');
}
在page.ts文件中:
stockList: Observable<any>;
this.stockList = this.fbService.getStockUserList();
in html:
<ul>
<li *ngFor="let item of stockList | async">
{{ item.age }}
</li>
</ul>
firebase库存清单中的具有唯一键的名称和年龄。 添加正在工作,但数据从firebase有问题并且还显示&#34; ngFor仅适用于数组元素&#34;和
typescript error
Cannot find type definition file for 'firebase'.
答案 0 :(得分:1)
回到firebase 4.8.0:
npm uninstall firebase
然后一旦鱼卸载,输入:npm cache clea
r npm install firebase@^4.8.0
"firebase": "^5.0.0-rc.1"
中依赖项中的package.json
并输入"firebase": "4.8.0"