Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md #3241

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Expand Up @@ -16,20 +16,32 @@ AngularFire smooths over the rough edges an Angular developer might encounter wh

## Example use

### Environment Config

Update the 'environment.ts' file with your firebase config information

Add the following to your 'app.modules.ts' file

```ts
import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
import { environment } from '../environments/environment';

@NgModule({
imports: [
provideFirebaseApp(() => initializeApp({ ... })),
provideFirebaseApp(() => initializeApp({ environment.firebase })),
provideFirestore(() => getFirestore()),
],
providers: [
{ provide: FIREBASE_OPTIONS, useValue: environment.firebase }
],
...
})
export class AppModule { }
```

Try it out in the component

```ts
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
Expand All @@ -52,8 +64,8 @@ interface Item {
export class AppComponent {
item$: Observable<Item[]>;
constructor(firestore: Firestore) {
const collection = collection(firestore, 'items');
this.item$ = collectionData(collection);
const items = collection(firestore, 'items');
this.item$ = collectionData(items) as Observable<Item[]>;
}
}
```
Expand Down