0

I am using firebase for authentication and using plain javascript (not AngularJS or any other framework such as Angular2 or ionic). After successful signing up with google or Facebook, I want to display the user name, use email and user image.

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.
    var displayName = user.displayName;
    var email = user.email;
    var photoURL = user.photoURL;
} else {
    // User is not logged in, redirect to where you need to.
      console.log("Logged out");
}

The above is the snippet on the page which should show up after successful sign up.

And I used the following to display the details, but the page showed up just what is written within the tags.

<p class="isLoggedIn">Logged In: {{user_displayName}} ({{user_email}})<p>

Where am I going wrong?

Any kind of help would be greatly appreciated. Thanks.

Steve Doson
  • 703
  • 4
  • 16
  • 34

1 Answers1

0

your variables are only available inside the method you will not get them outside the function. Also if you are not using the AngularJS then you are doing it wrong to put values in html like this, its angular way to bind data to view.

See this on how to write data using plain javascript: https://stackoverflow.com/a/10507608/4428159

Umar Hussain
  • 3,461
  • 1
  • 16
  • 38
  • Right, `document.getElementById('sign-in-status').textContent = 'Signed in'; document.getElementById('account-details').textContent = JSON.stringify({ displayName: displayName, email: email, phoneNumber: phoneNumber, photoURL: photoURL, uid: uid, accessToken: accessToken, providerData: providerData }, null, ' ');` this was needed within the scripts – Steve Doson Sep 06 '17 at 06:36