使用离子和角度应用程序无法进入AngularFire的数据

时间:2018-01-13 09:44:26

标签: angular firebase ionic-framework firebase-realtime-database angularfire

我收到错误,并且使用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'.

1 个答案:

答案 0 :(得分:1)

回到firebase 4.8.0:

  • 在CLI中,项目路径类型为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"