Skip to content

Commit

Permalink
Update Firestore example to use @for and AsyncPipe (#3570)
Browse files Browse the repository at this point in the history
  • Loading branch information
DellaBitta authored Oct 23, 2024
1 parent f379433 commit 94e57c6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/install-and-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ Open `/src/app/app.component.ts`, and make the following changes to :

```ts
import { Component, inject } from '@angular/core';
import { AsyncPipe } from '@angular/common';
import { Firestore } from '@angular/fire/firestore';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
styleUrls: ['app.component.css'],
imports: [AsyncPipe],
})
export class AppComponent {
firestore: Firestore = inject(Firestore);
Expand All @@ -64,11 +66,14 @@ In `/src/app/app.component.ts`:

```ts
import { Component, inject } from '@angular/core';
import { Firestore, collection, collectionData } from '@angular/fire/firestore';
import { AsyncPipe } from '@angular/common';
import { Observable } from 'rxjs';
import { Firestore, collection, collectionData } from '@angular/fire/firestore';

@Component({
selector: 'app-root',
standalone: true,
imports: [AsyncPipe],
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
Expand All @@ -87,9 +92,9 @@ Open `/src/app/app.component.html`:

```html
<ul>
<li class="text" *ngFor="let item of items$ | async">
{{item.name}}
</li>
@for (item of items$ | async; track item) {
<li>{{ item.name }}</li>
}
</ul>
```

Expand Down

0 comments on commit 94e57c6

Please sign in to comment.