我已经设置了一个 authenticatedRoute 来重定向到我的应用程序中的登录路由。但是,我在过渡期间收到一条奇怪的错误消息。
Error while loading route: undefined ember.js?body=1:361
Uncaught undefined
这些错误在 ember 源代码中的某个地方,所以我不确定我的代码是如何设置它的。我已经查看了几次,找不到我哪里出错了
App.AuthenticatedRoute = Ember.Route.extend
beforeModel: (transition) ->
if !App.Auth.signedIn
return Ember.RSVP.reject();
error: (reason, transition) ->
loginController = @controllerFor('login')
loginController.set('afterLoginTransition', transition)
@transitionTo('login')
App.LoginRoute = Ember.Route.extend()
App.PromptsRoute = App.AuthenticatedRoute.extend
model: -> App.Prompt.find()
App.LoginController = Ember.Controller.extend
email: null
password: null
remember: true
loginError: null
afterLoginTransition: null
login: () ->
self = @
App.Auth.signIn
data:
email: @get 'email'
password: @get 'password'
remember: @get 'remember'
.done (response) ->
self.clearForm()
self.loginSucceeded()
.fail (response) ->
self.set('loginError', "Your username or password was incorrect. Please try again")
clearForm: ->
@set('loginError', null)
@set('email', null)
@set('password', null)
@set('remember', true)
loginSucceeded: ->
transition = @get('afterLoginTransition')
if transition
transition.retry()
else
alert("Boink")