我的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
并且没有效果
答案 0 :(得分:3)
Controller有transitionToRoute
方法:
controller.transitionToRoute('auth');