Angularfire: Unwrapping property of an Object

Created on 10 May 2016  路  2Comments  路  Source: angular/angularfire

Please let me know what I am doing wrong. The notes seem to show you can access the properties of an object in this way but that is on a FirebaseListObservable rather than a FirebaseObjectObservable so I am not sure how to do it.

In constructor:
this.update = af.database.object('/webTest/update');

In View:
{{ update | async | json}} {{ update.pemdos | async }}

The first on outputs the json:
{ "asdf": 1234, "fdsa": "rewq", "pemdos": "asdf" }

The second is blank.

The full code can be found:
https://github.com/dcunited08/firebase-test/blob/angular2/src/app/firebase-test.component.ts
https://github.com/dcunited08/firebase-test/blob/angular2/src/app/firebase-test.component.html

Most helpful comment

You should be using the async pipe before trying to output any properties.

{{ (update | async)?.pemdos }}

The ? is an example of using the elvis operator which you can read more about here.

All 2 comments

You should be using the async pipe before trying to output any properties.

{{ (update | async)?.pemdos }}

The ? is an example of using the elvis operator which you can read more about here.

@rosslavery Thank you for the assistance.

Was this page helpful?
0 / 5 - 0 ratings