【发布时间】:2014-05-25 23:19:52
【问题描述】:
每当用户登录时,我都会尝试设置一个布尔变量。
App.ApplicationRoute = Ember.Route.extend({
isLoggedIn: false,
init: function() {
if (loggedIn) {
this.set('isLoggedIn', true);
} else {
console.log(error)
this.set('isLoggedIn', false);
}
});
}
});
但是,在this.set() 我得到:
Uncaught TypeError: undefined is not a function
有什么想法吗?
我认为处理用户会话的最佳位置是App.ApplicationRoute,因为它是一切的根源。这会导致问题吗?
更新: 这里有反馈是当前/完整的代码。
App.ApplicationRoute = Ember.Route.extend({
isLoggedIn: false,
init: function() {
this._super();
auth = new FirebaseSimpleLogin(appRef, function(error, user) {
if (user) {
console.log(user)
this.set('isLoggedIn', true);
} else {
console.log(error)
this.set('isLoggedIn', false);
}
});
}
})
所以我之前遗漏了我的 Firebase 代码,因为我认为它并不相关,但为了追查问题,我将其添加进去。
【问题讨论】:
标签: javascript ember.js firebase