我正尝试第一次从Cloud Firestore接收数据,但是我没有收到任何错误也没有任何输出..请帮助 这是输出的屏幕截图,除了屏幕上的一个点外,我什么也没收到。
我没有在这里使用服务,而是在组件本身中调用了
html文件
<ul>
<li class="text" *ngFor="let item of items | async">{{item.name}}</li>
</ul>
.ts文件
import { Component } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
items: Observable<any[]>;
constructor(db: AngularFirestore){
this.items = db.collection('items').valueChanges();
}
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule ,FirestoreSettingsToken} from '@angular/fire/firestore';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebase,'asd'),
AngularFirestoreModule, // imports firebase/firestore, only needed for database features
AngularFireAuthModule, // imports firebase/auth, only needed for auth features,
AngularFireStorageModule // imports firebase/storage only needed for storage features
],
providers: [
{ provide: FirestoreSettingsToken, useValue: {} }
],
bootstrap: [AppComponent]
})
export class AppModule { }