Angularfire and FirebaseListObservable has no expo

2019-03-19 08:28发布

FirebaseListObservable and Angularfire has no exported member "angularfire2" when i am creating Ionic 2 app import both files in home.ts

My Cordova and ionic version is Cordova version 6.5.0 Ionic Version 2.2.3 Node version 6.10.2 typings version 2.1.1 typescript version 2.3.2

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {AngularFire, FirebaseListObservable} from 'angularfire2';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, af:AngularFire ) {
}
}

5条回答
一纸荒年 Trace。
2楼-- · 2019-03-19 09:09

Ashish Jha, You're right, as the new update uses AngularFirestore and it uses a simple Observable instead of FirebaseListObservable I wasn't able to import FirebaseListObservable and was struggling to do a push(). Changing

import {AngularFire, FirebaseListObservable} from 'angularfire2'; 

to

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated";

worked fine for me, thank you!

查看更多
Lonely孤独者°
3楼-- · 2019-03-19 09:13

The solution is to simply change this line

import {AngularFire, FirebaseListObservable} from 'angularfire2'; 

to

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database"; 

*REFRENCE

查看更多
\"骚年 ilove
4楼-- · 2019-03-19 09:13

Changing it to the following solved it for me:

import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
查看更多
趁早两清
5楼-- · 2019-03-19 09:24

As of AngularFire 2.0.4 and above FirebaseListObservable and FirebaseObjectObservable are now called AngularFireList and AngularFireObject.

Example:

import { AngularFireDatabase, AngularFireObject } from 'angularfire2/database';
查看更多
戒情不戒烟
6楼-- · 2019-03-19 09:34

The solution that worked for me was to change this line

import {AngularFire, FirebaseListObservable} from 'angularfire2'; 

to

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated";

You can read more about it here https://github.com/angular/angularfire2/blob/master/CHANGELOG.md

查看更多
登录 后发表回答