Skip to content

Commit 133b908

Browse files
mukesh51davideast
authored andcommitted
* Update 1 - Install and Setup.md Remove ModuleId: module.id, as WebPack takes care internally and is causing errors * Update @moduleName Update ModuleName to make it consistent * Update to Retrieve Data as Object The Tutorial needs to be in flow with "Install and Setup Page". Other pages needs to be looked into, which I'll do later.
1 parent 45750de commit 133b908

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

docs/1-install-and-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const firebaseConfig = {
8383
declarations: [ AppComponent ],
8484
bootstrap: [ AppComponent ]
8585
})
86-
export class MyAppModule {}
86+
export class AppModule {}
8787

8888
```
8989

@@ -96,7 +96,7 @@ import { Component } from '@angular/core';
9696
import { AngularFire, FirebaseListObservable } from 'angularfire2';
9797

9898
@Component({
99-
moduleId: module.id,
99+
100100
selector: 'app-root',
101101
templateUrl: 'app.component.html',
102102
styleUrls: ['app.component.css']
@@ -118,7 +118,7 @@ import { Component } from '@angular/core';
118118
import { AngularFire, FirebaseListObservable } from 'angularfire2';
119119

120120
@Component({
121-
moduleId: module.id,
121+
122122
selector: 'app-root',
123123
templateUrl: 'app.component.html',
124124
styleUrls: ['app.component.css']

docs/2-retrieving-data-as-objects.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ The guide below demonstrates how to retrieve, save, and remove data as objects.
1010

1111
AngularFire is an injectable service, which is injected through the constructor of your Angular component or `@Injectable()` service.
1212

13+
If you've followed the earlier step "Installation and Setup" your `/src/app/app.component.ts` should look like below.
14+
1315
```ts
1416
import { Component } from '@angular/core';
15-
import { AngularFire } from 'angularfire2';
17+
import { AngularFire, FirebaseListObservable } from 'angularfire2';
1618

1719
@Component({
18-
moduleId: module.id,
19-
selector: 'app',
20-
template: 'app.component.html',
20+
selector: 'app-root',
21+
templateUrl: 'app.component.html',
2122
styleUrls: ['app.component.css']
2223
})
2324
export class AppComponent {
25+
items: FirebaseListObservable<any[]>;
2426
constructor(af: AngularFire) {
25-
27+
this.items = af.database.list('items');
2628
}
2729
}
2830
```
2931

32+
In this section, we're going to modify the `/src/app/app.component.ts` to retreive data as object.
33+
3034
## Create an object binding
3135

3236
Data is retrieved through the `af.database` service.
@@ -48,12 +52,15 @@ const absolute = af.database.object('https://<your-app>.firebaseio.com/item');
4852
To get the object in realtime, create an object binding as a property of your component or service.
4953
Then in your template, you can use the `async` pipe to unwrap the binding.
5054

55+
Replace the FirebaseListObservable to FirebaseObjectObservable in your `/src/app/app.component.ts` as below.
56+
Also notice the templateUrl changed to inline template below:
57+
5158
```ts
52-
import {Component} from 'angular2/core';
59+
import {Component} from '@angular/core';
5360
import {AngularFire, FirebaseObjectObservable} from 'angularfire2';
5461

5562
@Component({
56-
selector: 'app',
63+
selector: 'app-root',
5764
template: `
5865
<h1>{{ (item | async)?.name }}</h1>
5966
`,
@@ -129,8 +136,7 @@ import { Component } from '@angular/core';
129136
import { AngularFire, FirebaseObjectObservable } from 'angularfire2';
130137

131138
@Component({
132-
moduleId: module.id,
133-
selector: 'app',
139+
selector: 'app-root',
134140
template: `
135141
<h1>{{ item | async | json }}</h1>
136142
<input type="text" #newname placeholder="Name" />
@@ -141,7 +147,7 @@ import { AngularFire, FirebaseObjectObservable } from 'angularfire2';
141147
<button (click)="delete()">Delete</button>
142148
`,
143149
})
144-
export class RcTestAppComponent {
150+
export class AppComponent {
145151
item: FirebaseObjectObservable<any>;
146152
constructor(af: AngularFire) {
147153
this.item = af.database.object('/item');

0 commit comments

Comments
 (0)