Lex Podgorny
Lex Podgorny

Reputation: 2930

Emberjs: How to get to a route parameter passed in via url in controller

Consider routes:

this.resource('things', {path: '/things/:id'}, function () {
  this.route('edit');
});

Inside controller of the edit, how do I access the :id?

Upvotes: 0

Views: 989

Answers (1)

Ember Freak
Ember Freak

Reputation: 12872

You can use the paramsFor method in the route to get parent route parameters. So in your case you can also use the setupController hook of the edit route,

setupController(controller,model){
 this._super(...arguments);
 let { id } = this.paramsFor(this.routeName);
 controller.set('thingsId',id);
}

Upvotes: 2

Related Questions