mardi 6 octobre 2015

Get dynamic segment value

I'm using ember-cli and ember 2.

I've this route:

Router.map(function() {
  this.route('item', { path: '/item/:name' });
});

But when I try to use params.name inside the item.hbs template I get undefined.

I've tried defining a route for item in this way:

export default Ember.Route.extend({
  model(params) {
    this.set('params', params);
  },
  setupController(controller, model) {
    controller.set('params', this.get('params'));
    this._super(controller, model);
  }
});

But then, inside params i get Object {name: null} (even if the URL has the :name segment filled.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire