Javascript 函数后无法重定向到控制器
我在我的Javascript 函数后无法重定向到控制器,javascript,ember.js,Javascript,Ember.js,我在我的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: {
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
,但没有很好地工作controller有transitionRoute
方法:
controller.transitionToRoute('auth');
控制器具有
transitionRoute
方法:
controller.transitionToRoute('auth');