mercredi 3 août 2016

cannot redirect to controller after function

I have an action in my application.js route that logs in with Github and then redirects to a controller called auth, as following:

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);
       });
    }
  }
});

but I get the following 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)

I don't really know what I missing here. I already tried var controller = this.controller and didn't worked as well




Aucun commentaire:

Enregistrer un commentaire