johncorser
johncorser

Reputation: 9842

Firebase not found in angularjs

I am making an angularJS application, and I plan to use Firebase for simple authentication.

My index.html file includes

    <script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
    <script src="scripts/login.js"></script>

My login.js looks like this at the moment:

$(document).ready(function(){
  var myRef = new Firebase("https://my_app.firebaseio.com");
  var auth = new FirebaseSimpleLogin(myRef, function(error, user) {
    if (error) {
      // an error occurred while attempting login
      console.log(error);
    } else if (user) {
      // user authenticated with Firebase
      console.log("User ID: " + user.uid + ", Provider: " + user.provider);
    } else {
       // user is logged out
    }
  });
  var authRef = new Firebase("https://my_app.firebaseio.com/.info/authenticated");
  authRef.on("value", function(snap) {
    if (snap.val() === true) {
      alert("authenticated");
    } else {
      alert("not authenticated");
    }
  });
  auth.login('password', {
    email: '[email protected]',
    password: 'password',
  });
  console.log(auth); 
});

All I really want to do with this is test whether I can log in, and what the auth object will look like after a login.

Later, I will integrate the login into a ng-model to pass the data that way rather than just passing it hard coded.

The problem right now is that this code doesn't even run, I get an error back from the javascript console:

Uncaught ReferenceError: Firebase is not defined 

Why is this happening?

Upvotes: 0

Views: 535

Answers (1)

runTarm
runTarm

Reputation: 11547

It seems you haven't included the firebase.js script.

Only the firebase-simple-login.js isn't enough, it require firebase.js.

<script src="https://cdn.firebase.com/js/client/1.0.17/firebase.js"></script>
<script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
<script src="scripts/login.js"></script>

Upvotes: 3

Related Questions