app.factory("Auth", ["$firebaseAuth", function($firebaseAuth) {
var ref = new Firebase("https://XXXXXX.firebaseio.com/");
var auth = $firebaseAuth(ref);
var Auth = {
login: function(){
return auth.$authWithPassword({
"email": "[email protected]", //hard-coding in the email & password for testing
"password": "1"
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Login Success!", authData);
}
});
}
return Auth;
}]);
app.controller("SampleCtrl", ["$scope", "Auth", "$firebaseAuth", function($scope, Auth, $firebaseAuth) {
$scope.login = Auth.login();
}]);
I am trying to create a factory to use the angularFire user authentication function
<button ng-click="login()">Login</button>
It returns an error: TypeError: Cannot read property '0' of null
What am I doing wrong?
PLUNKER