Undefined Function from Provider


#1

I have this code

	loginFB() {
    	this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider()).then(function(result) {
  			// This gives you a Facebook Access Token.
  			var token = result.credential.accessToken;
  			// The signed-in user info.
  			const user = result.user;
  			console.log(user);
        this.pPicture.updatepicURL(user.photoURL);
		});
	};

calling a function from the below provider code

import { Injectable } from '@angular/core';

/*
  Generated class for the PpProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class PpProvider {
	public picURL:string = 'https://image.flaticon.com/icons/png/512/15/15081.png';
	constructor() {
		console.log('Hello PpProvider Provider');
	}

	updatepicURL(url) {
		return console.log(url);
	}
}

the issue is that it says cannot access pPicture of undefined


#2

You have not pass the parameter in updatepicURL


#3

Oh yeah, typo
Thanks, but that doesn’t solve the problem


#4

Cannot read property ‘pPicture’ of undefined


#5

Anyone help? What am I doing wrong?