K
K
Klaus Kater2016-04-15 17:50:09
Ember.js
Klaus Kater, 2016-04-15 17:50:09

How to customize display of model list in emberjs?

Hello.
I'm trying to display multiple lists of models on a page.

route/index.js
export default Ember.Route.extend({
  model() {
      return Ember.RSVP.hash({
        model1: this.store.queryRecord('model1', { filter: { parent: '' } }),
        model2: this.store.query('model2', { filter: { open: true }})
      });
   }
}
template/index.hbs
{{test-component name=model.model1.name model_id=model.model1.id}}
{{#each model.model2 as |model2t|}}
  <p>{{ model2t.text }}</p>
{{/each}}

In another place I get a model, and I make it to her.
model2.set('open', true);
But apparently Amber and I misunderstood each other again, because the model does not appear on the page. Maybe it's in several models in the display?
I thought that the entire application shared storage, and that if you change the parameter in some place, then the route filter should be updated and catch the new model.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Romanov, 2016-04-15
@kurojneko

Your route makes a request and outputs server-prepared data. The promise itself does not keep track of the repository.
In previous versions of ember-data, store had a filter method that filtered data from the server and watched the models update when needed, which is exactly what you want. Now this method has been moved to a separate addon ember-data-filter .

A
Abdulla Mursalov, 2016-04-15
@amaprograma

Query params

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question