简体   繁体   English

模块C:// ..没有“ firebaseObservable”导出的成员错误

[英]The module C://.. has no “firebaseObservable” exported member error

im trying to follow an angular/firebase tutorial for my class. 我试图按照我的课程的角度/火力发烧教程。 (you can find it here https://www.barbarianmeetscoding.com/blog/2017/06/09/from-idea-to-reality-in-under-50-minutes-mostly-with-angular-and-firebase/ ) i have follow it word by word but im getting an error importing the FirebaseListObservable in my component, it says it has no exported member i have consulted all the similar questions but i cant find the solution. (您可以在这里找到它https://www.barbarianmeetscoding.com/blog/2017/06/09/from-idea-to-reality-in-under-50-minutes-mostly-with-angular-and-firebase/ )我已逐字跟踪它,但是在将FirebaseListObservable导入到我的组件时出现错误,它说它没有导出的成员,我已经咨询了所有类似的问题,但是我找不到解决方案。

my component is: 我的组件是:

import { Component, OnInit } from '@angular/core';
import { Baby } from '../baby';

import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { RandomPickerService } from '../random-picker.service';

@Component({
selector: 'app-babies',
templateUrl: './babies.component.html',
styleUrls: ['./babies.component.css']
})
export class BabiesComponent implements OnInit {
babies: FirebaseListObservable<Baby[]>;

constructor(private db: AngularFireDatabase, private randomService: RandomPickerService) { }

ngOnInit() {
this.babies = this.db.list('/babies');
}

// create new baby!
giveBirth() {
// create new baby!
const newBaby = new Baby(this.pickRandomName());
const babies = this.db.list('/babies');
babies.push(newBaby);
}

pickRandomName() {
const names = ['Erik', 'Nicolas', 'Fabian', 'Jaime', 'Anderson', 'Luisa', 'Laura', 'Gustavo', 'Chicuazuque', 'Felipe', 'Juan', 'Jose'];
return this.randomService.pickAtRandom(names);
}

}

My routing-module is this one: 我的路由模块是这个:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BabiesComponent } from './babies/babies.component'

const routes: Routes = [
{
path: 'babies',
children: [{
    path: '',
    component: BabiesComponent
}],
},
{
  path: '**',
  redirectTo: 'babies'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

and my app module is this one: 我的应用程序模块是这样的:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FirebaseApp } from 'angularfire2';
import { AppComponent } from './app.component';
import { BabiesComponent } from './babies/babies.component';
import { AppRoutingModule } from './/app-routing.module';
import { HttpModule, Http } from '@angular/http';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { RandomPickerService } from './random-picker.service';
// Environment configuration
import { environment } from '../environments/environment';

@NgModule({
declarations: [
AppComponent,
BabiesComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireDatabaseModule,
HttpModule
],
bootstrap: [AppComponent],
providers: [RandomPickerService]
})
export class AppModule { }

It is because with new angularfire2 update, FirebaseListObservable has been deprecated. 这是因为随着新的angularfire2更新,FirebaseListObservable已被弃用。 If you still want to use FirebaseListObservable then change your import package from 'angularfire2/database' to 'angularfire2/database-deprecated' Other wise you can check anguarlfire2 documentation on GitHub to find out how to use their new AngularFireList. 如果仍要使用FirebaseListObservable,则将导入包从“ angularfire2 / database”更改为“ angularfire2 / database-preprecated”。否则,您可以查看GitHub上的anguarlfire2文档,以了解如何使用其新的AngularFireList。 https://github.com/angular/angularfire2/blob/master/docs/version-5-upgrade.md https://github.com/angular/angularfire2/blob/master/docs/version-5-upgrade.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM