jeudi 11 août 2016

this.transitionToRoute not working in my controller Ember

I am using a controller to read the value selected on a drop down menu, take in parameters of some input fields and then save the record. It creates the record and takes in the information just fine. My problem lies when I try to transition to another page at the end of the action. I keep getting the error: Cannot read property 'transitionToRoute' of undefined

I am completely stumped. Any ideas?

Here is my controller code:

var teamId;
export default Ember.Controller.extend({
    auth: Ember.inject.service(),
    actions: {
        onSelectEntityType: function(value) {
         console.log(value);
         teamId = value;
         return value;
      },
      createProcess: function(processName, processDescription) {
        var currentID = this.get('auth').getCurrentUser();
        let team = this.get('store').peekRecord('team', teamId);
        let user = this.get('store').peekRecord('user', currentID);
        let process = this.get('store').createRecord('process', {
            team: team,
            user: user,
            name: processName,
            description: processDescription
        });
        process.save().then(function () {
        this.transitionToRoute('teams', teamId);
      });
    }

    }
});

Here is the corresponding route:

export default Ember.Route.extend({
    auth: Ember.inject.service(),
    model: function() {
        var currentID = this.get('auth').getCurrentUser();
        return this.store.find('user', currentID);
    }
});




Aucun commentaire:

Enregistrer un commentaire