Skip to content

Commit a14dec0

Browse files
cweidingerdavideast
authored andcommitted
Update "Retrieving the snapshot" code snipbit in docs (angular#334)
* Fixed af.databasse.list "Retrieving the snapshot" While I discovered that including `import 'rxjs/add/operator/do';` made the previous example compile, it still didn't give me the snapshot. The code I'm committing works with angularfire2 : ^2.0.0-beta.2 * Update "Retrieving the snapshot" example typeof snapshot.key === 'string'. I was also naive enough to believe that it was snapshot.value() so I included the snapshot.val() in the example as well.
1 parent ac8c6be commit a14dec0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ AngularFire2 unwraps the Firebase DataSnapshot by default, but you can get the d
176176

177177
```ts
178178
this.item = af.database.object('/item', { preserveSnapshot: true });
179-
this.item.subscribe(snapshot => console.log(snapshot.key()));
179+
this.item.subscribe(snapshot => {
180+
console.log(snapshot.key)
181+
console.log(snapshot.val())
182+
});
180183
```
181184

182185
## Querying?

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,12 @@ AngularFire2 unwraps the Firebase DataSnapshot by default, but you can get the d
196196
```ts
197197
this.items = af.database.list('/items', { preserveSnapshot: true });
198198
this.items
199-
.do(snapshots => {
200-
snapshots.forEach(snapshot => console.log(snapshot.key()));
199+
.subscribe(snapshots => {
200+
snapshots.forEach(snapshot => {
201+
console.log(snapshot.key)
202+
console.log(snapshot.val())
203+
});
201204
})
202-
.subscribe(snapshots => console.log(snapshots.length));
203205
```
204206

205207
###[Next Step: Querying lists](4-querying-lists.md)

0 commit comments

Comments
 (0)