以下、私はサインアップコードを持っています。これは、アカウント作成時にユーザーのテーブルにデータを追加することについて私が持っていたprevious questionから来ています。コードは次のとおりです。今、私はこの情報を取得したいと私のプロファイルコンポーネントに置き、この時間は取り出すでしょうFirebase角度2ユーザテーブルからデータを取得
email|''
password|''
username|'Roy'
net_worth|'5000'
:
signup(){
firebase.auth().createUserWithEmailAndPassword(useremail, userpassword)
.then(function(response) {
var updates = {};
updates['/users/' + response.uid] = { email: useremail, password: userpassword, net_worth : 5000, username : 'Roy' };
firebase.database().ref().update(updates);
});
}
明確にするために、私のスキーマのようなものになりますそのデータ。
プロファイルコンポーネント
export class ProfileComponent implements OnInit {
private usermail: string;
private net_worth: string;
constructor(){}
ngOnInit(){
this.usermail = '';
this.net_worth = '';
var user = firebase.auth().currentUser;
if (user != null) {this.usermail = user.email;}
}
}
は、このコードは、認証から私に、ユーザーの電子メールを与えるために動作しますが、それは私の中で、他の情報を返すには動作しません:私は、次のされているもの瞬間スキーマ(net_worth
とusername
など)。認証機能ではなく、データベーステーブルに格納されているので想像してください。
指定されたユーザーの詳細を取得するには、ユーザー生成IDをどのように呼びますか?具体的には、username
とnet_worth
?