Ionic 1.x和firebase - 实现onAuthStateChanged时遇到麻烦

时间:2017-05-20 16:35:13

标签: angular firebase ionic-framework

我是ionic 1.x和firebase的新手,尝试应用onAuthStateChanged方法来跟踪当前记录的用户和身份验证更改。我可以使用电子邮件和密码注册新用户,能够登录和注销,但在实施onAuthStateChanged时遇到了麻烦。 这是我的services.js文件:

angular.module('app.services', [])
.service("fireBaseService", function(){

    //sign up
    this.signUp = function(userEmail, password){
      ...
    }

    //sign in
    this.signIn = function(userEmail, password){
     ...
    }

    this.signOut = function(){
    ....
})
.service("authObserver", function(){

    this.auth = firebase.auth().onAuthStateChanged(function(user) {
        if (user) {
            console.log("is logged in");
        } else {
            console.log("signed out!");
            // No user is signed in.
        }
    });
});

有什么想法吗?

0 个答案:

没有答案