2017-05-26 85 views
0

我無法呈現從Firebase檢索到的對象的值。以使這項工作是如下的接近我:Angular2呈現多級Firebase對象

僅供參考,數據來自於這裏,它做精:

的數據是類似的結構如此:

userProfile:FirebaseObjectObservable<any>; 

db.object('/users/'+auth.uid,{ preserveSnapshot: true }) 
    .subscribe(snapshot => { 
     this.userProfile = snapshot; 
}); 

在我的HTML我可以渲染出具有下列對象:

{{ userService.userProfile | json }} 

OUTPUT rendered is: { "email": "[email protected]", "provider": "password" } // THIS is GREAT!!!! now I just need to extract the email... and will need more values later 

現在我只需要渲染的電子郵件價值......但沒有我做的工作,事情我已經試過渲染沒有結果

{{ userService.userProfile.email }} //nothing  
{{ userService.userProfile.email | json }} //nothing 
{{ userService.userProfile.email | json | async }} //nothing 
{{ userService.userProfile.email | async }} //nothing 
{{ (userService.userProfile.email) | async }} //nothing 
{{ (userService.userProfile.email) | json }} //nothing 
{{ (userService.userProfile?.email) | json }} //nothing 
{{ (userService.userProfile?.email) | async }} //nothing 
{{ (userService.userProfile)?.email | async }} //nothing 
{{ (userService.userProfile)?.email | json }} //nothing 
{{ (userService.userProfile)?.email }} //nothing 
{{ (userService)?.userProfile.email }} //nothing 
{{ userService?.userProfile?.email }} //nothing 
{{ userService?.userProfile?.email | async }} //nothing 
{{ userService?.userProfile?.email | json }} //nothing 

我確定我做錯了什麼,但不知道爲什麼它在高層次上工作,但不輸出特定的屬性。

+0

什麼是'userService'? – Pengyy

+0

userService是從其注入的父組件。 – user1019416

回答

0

前幾天我有類似的問題。請嘗試:

snapshot.val()