vendredi 25 novembre 2016

Getting specific item with findRecord

I'm new at ember and as first app I'm trying to build a little online shop. I can receive "all products" as product overview but not one specific product by id.

I have following in the router.js:

Router.map(function() {
  this.route('products');
  this.route('product', {path: 'products/:product_id'});
});

My products.js (wich works):

import Ember from 'ember';

export default Ember.Route.extend({
  model(){
    return this.get('store').query('product', {});
  }
});

And the product.js (wich does generate the problem):

import Ember from 'ember';

export default Ember.Route.extend({
  model(params){
    return this.store.findRecord('product', params.product_id);
  }
});

The project is available under http://ift.tt/2gopO5z

Maybe you could help me out here. Thanks in advance! :)




Aucun commentaire:

Enregistrer un commentaire