Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4829

How to get parent route params in the adapter?

$
0
0

@rael.venturus wrote:

Hello!

I'm currently working in a project powered by Ember-CLI with Ember 2.4.1 and Ember Data 2.4.0, and i cant figure out how to get all informations i need to set the buildURL for a model in the adapter file.

As i can't publish any code of the project, here is some example to illustrate the problem:

router.js:

Router.map(function() {
  this.route('foo', {path: '/foo/:fooId'}, function(){
    this.route('bar', {path: '/bar/barId/list'});
  });
});

adapter/bar.js:

buildURL: function(model,id,snapshot,type){
  return '/api/foobar/:fooId/:barId/list
}

The problem:

So, based on the adapter below, the full URL should be something like: http://localhost:3000/api/foo/2/bar/13/list and the adapter needs the variables fooId = 2 and barId = 13 to build this URL... The problem is that there is no fooId and barId in the adapter.

So, what's the best approach to send this values to the adapter, and how to send other custom variables (if possible) ? e.g.: let's say i need to send a boolean 'foobarAttribute' to the adapter to generate the correct URL.

Thanks in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles