jeudi 10 août 2017

How to get `model` property in `route` path?

How can I get the current route model within current routes action method? I am keep getting error. any one help me here?

my route:

import Ember from 'ember';

export default Ember.Route.extend({
  model: function(params) {

    if(this.store.hasRecordForId('card-list', params.id)){
        return Ember.RSVP.hash({
            model: this.store.peekRecord('card-list', params.id )
        })
    }
  },
  actions:{
    formValidateBeforeNext:function(){
        this.modelFor(this.routeName).get("id");//not works
        console.log(this.controller.get('model').get("id"));//not works
        console.log(this.get('model').get("id"))//not works
        return;
        // this.transitionTo('cs2i.balance.balanceReview');
    }
  }
});

getting error as : TypeError: Cannot read property 'get' of null




Aucun commentaire:

Enregistrer un commentaire