Skip to content

Commit 5d0c552

Browse files
mukesh51katowulf
authored andcommitted
docs(lists): Fixing various typos and improving readability
Updated Tutorial to go in flow with the previous sections. export was missing, selector was not correct. removed moduleId, which could have thrown errors for new users. Component name has been corrected.
1 parent 6f5231c commit 5d0c552

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

docs/3-retrieving-data-as-lists.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,33 @@ The guide below demonstrates how to retrieve, save, and remove data as lists.
99
**Make sure you have bootstrapped your application for AngularFire2. See the Installation guide for bootstrap setup.**
1010

1111
AngularFire is an injectable service, which is injected through the constructor of your Angular component or `@Injectable()` service.
12+
In the previous step, we modified the `/src/app/app.component.ts` to retrieve data as object. In this step, let's start with a clean slate.
13+
14+
Replace your `/src/app/app.component.ts` from previous step to look like below.
1215

1316
```ts
14-
import {Component} from '@angular/core';
15-
import {AngularFire} from 'angularfire2';
17+
import { Component } from '@angular/core';
18+
import { AngularFire } from 'angularfire2';
1619

1720
@Component({
18-
selector: 'app',
19-
templateUrl: 'app/app.html',
21+
selector: 'app-root',
22+
templateUrl: 'app.component.html',
23+
styleUrls: ['app.component.css']
2024
})
21-
class AppComponent {
25+
export class AppComponent {
2226
constructor(af: AngularFire) {
23-
27+
2428
}
2529
}
2630
```
2731

32+
In this section, we're going to modify the `/src/app/app.component.ts` to retreive data as list, but before that let's look at ways around how to bind to a list.
33+
2834
## Create a list binding
2935

3036
Data is retrieved through the `af.database` service.
3137

32-
There are four ways to create an object binding:
38+
There are three ways to create an object binding:
3339

3440
1. Relative URL
3541
1. Absolute URL
@@ -54,21 +60,23 @@ const queryList = af.database.list('/items', {
5460
To get the list in realtime, create a list binding as a property of your component or service.
5561
Then in your template, you can use the `async` pipe to unwrap the binding.
5662

63+
Update `/src/app/app.component.ts` to import `FirebaseListObservable` from angularfire2 and iterate thru the list once data is retrieved. Also note the change in attribute `templateUrl` to inline `template` below.
64+
5765
```ts
5866
import {Component} from '@angular/core';
5967
import {AngularFire, FirebaseListObservable} from 'angularfire2';
6068

6169
@Component({
62-
selector: 'app',
63-
templateUrl: `
70+
selector: 'app-root',
71+
template: `
6472
<ul>
6573
<li *ngFor="let item of items | async">
66-
{{ item.name }}
74+
{{ item | json }}
6775
</li>
6876
</ul>
6977
`,
7078
})
71-
class AppComponent {
79+
export class AppComponent {
7280
items: FirebaseListObservable<any>;
7381
constructor(af: AngularFire) {
7482
this.items = af.database.list('/items');
@@ -147,8 +155,7 @@ import { Component } from '@angular/core';
147155
import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2';
148156

149157
@Component({
150-
moduleId: module.id,
151-
selector: 'app',
158+
selector: 'app-root',
152159
template: `
153160
<ul>
154161
<li *ngFor="let item of items | async">
@@ -162,7 +169,7 @@ import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'a
162169
<button (click)="deleteEverything()">Delete All</button>
163170
`,
164171
})
165-
export class RcTestAppComponent {
172+
export class AppComponent {
166173
items: FirebaseListObservable<any>;
167174
constructor(af: AngularFire) {
168175
this.items = af.database.list('/messages');

0 commit comments

Comments
 (0)