添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

The code which is throwing this is:

constructor() {
    this.userProfileRef = firebase.database().ref(`userProfile/${firebase.auth().currentUser.uid}`);

Not sure why… need help/suggestion

public userProfileRef:firebase.database.Reference; constructor() { this.userProfileRef = firebase.database().ref(`userProfile/${firebase.auth().currentUser.uid}`);

Struggling to put the code for ionViewDidLoad()

uh put ionViewDidLoad() after your constructor, just as any other function inside your class. If you’re using AngularFire, why don’t follow the docs over here?

https://github.com/angular/angularfire2/blob/master/docs/Auth-with-Ionic3-Angular4.md

they are pretty well explained and work perfectly as far as I can tell :slight_smile:

Provide context for links
Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.

I think it is a good practice to do this, instead of only linking the external resource

Also, the thread is 6 months old, not 1.5 years.

public afDB: AngularFireDatabase, public auth: AuthProvider) { this.auth.Session.subscribe(session => { if (session) { this.userId = session.uid;

Yes you’re absolutely right that it’s good practice. Nonetheless, this was posted june 2016. It doesn’t really matter, I agree with you that it wasn’t the best answer possible.

If you were around here a little longer you would have known that I’m quite an active contributor on this forum and I believe I’ve helped quite a lot of people around here with my answers. Little bit annoying to get such a negative answer on an old post, as where I probably could and would have helped you if you just asked.

Glad you fixed your issue and posted the solution.

**import { Injectable } from ‘@angular/core’;
import { AngularFire } from ‘angularfire2’;
import { User } from ‘…/shared/interfaces’;

@Injectable()
export class AuthProvicer {

constructor(public af: AngularFire) {

updateUser(user: User) {
let currentUserRef = this.af.database.object(/users/${user.uid});
currentUserRef.set({
id: user.id,
uid: user.uid,
username: user.username,
email: user.email,
photo: user.photo

which place import you code.??