2016-08-03 61 views
0

後,我有我的application.js路由與Github上登錄,然後重定向到一個名爲AUTH控制器,如下動作:不能重定向到控制器功能

import Ember from 'ember'; 
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; 

export default Ember.Route.extend(ApplicationRouteMixin, { 
    actions: { 
    login() { 
     var controller = this.controllerFor('auth'); 
     this.get('torii').open('github-oauth2').then(function(authData){ 
     console.log(authData); 
     controller.transitionTo('auth'); 
     }, function(error){ 
     console.log(error); 
     }); 
    } 
    } 
}); 

,但我得到以下錯誤

ember.debug.js:19750 TypeError: controller.transitionTo is not a function 
at application.js:8 
at tryCatch (ember.debug.js:52155) 
at invokeCallback (ember.debug.js:52170) 
at publish (ember.debug.js:52138) 
at ember.debug.js:41257 
at invoke (ember.debug.js:990) 
at Object.flush (ember.debug.js:1054) 
at Object.flush (ember.debug.js:862) 
at Object.end (ember.debug.js:176) 
at Object.run (ember.debug.js:298) 

我真的不知道我在這裏錯過了什麼。 我已經嘗試過var controller = this.controller,並沒有工作,以及

回答

3

控制器具有transitionToRoute方法:

controller.transitionToRoute('auth');