Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 模块C://。。没有",;firebaseObservable“;导出的成员错误_Javascript_Node.js_Angular_Firebase - Fatal编程技术网

Javascript 模块C://。。没有",;firebaseObservable“;导出的成员错误

Javascript 模块C://。。没有",;firebaseObservable“;导出的成员错误,javascript,node.js,angular,firebase,Javascript,Node.js,Angular,Firebase,我试着在课堂上学习angular/firebase教程。(你可以在这里找到) 我一字不差地跟着它,但是我在导入我的组件中的FirebaseListObservable时出错了,它说它没有导出成员。我已经咨询了所有类似的问题,但我找不到解决方案 我的组成部分是: import { Component, OnInit } from '@angular/core'; import { Baby } from '../baby'; import { AngularFireDatabase, Fireb

我试着在课堂上学习angular/firebase教程。(你可以在这里找到) 我一字不差地跟着它,但是我在导入我的组件中的FirebaseListObservable时出错了,它说它没有导出成员。我已经咨询了所有类似的问题,但我找不到解决方案

我的组成部分是:

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);
}

}
我的应用程序模块是:

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 { }
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 { }

这是因为随着新的angularfire2更新,FirebaseListObservable已被弃用。如果您仍然希望使用FirebaseListObservable,则将导入包从“angularfire2/database”更改为“angularfire2/database deprecated”,否则您可以查看GitHub上的angularfire2文档,了解如何使用新的AngularFireList。

如果您使用的是angular 6(请在下次询问时指定),请尝试
npm i--save rxjs compat
。同时将firebase更新至最新版本