Answer the question
In order to leave comments, you need to log in
How to parse data from JSON and output it?
Mastering Ember. A simple task. How to parse data and output it? I am currently getting an error:
The Broccoli Plugin: [TemplateCompiler] failed with:
Error: Parse error on line 16:
...ody> {{ #each users as |use
r
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
urlForFindAll(id, modelName, snapshot) {
return 'users.json';
}
});
import Ember from 'ember';
export default Ember.Route.extend({
users(){
return this.store.findAll('user')
}
});
import DS from 'ember-data';
export default DS.Model.extend({
id: DS.attr('string')
});
{{ #each users as |user| }}
<tr>
<td>{{ user.id }}</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
{{ /each }}
Answer the question
In order to leave comments, you need to log in
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return this.store.findAll('user')
}
});
import DS from 'ember-data';
export default DS.Model.extend({
// id указывать не нужно
});
{{#each model as |user|}}
<tr>
<td>{{ user.id }}</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
{{ /each }}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question