I am using Ember.RSVP.hash to create different models in the same route, i successfully create the model records in the store, i can see the data in the console.
The problem is that i can only list one the two models in my template. ( repos name but not the commit message ).
Here the code
Route
var gitrepositoriesPromise = function() {
return Ember.$.ajax(reposUrl, {
success: function(repos) {
return repos.map(function(repo) {
return store.createRecord('repo', {
name: repo.name,
description: repo.description
});
});
},
error: function(reason) {
reject(reason);
}});
};
var gitactivitiesPromise = function() {
return Ember.$.ajax(eventsAct, {
success: function(events) {
return events.filter(function(event) {
return event.type == 'PushEvent';
}).forEach(function(item){
return item.payload.commits.map(function(commit){
return store.createRecord('commit', {
message: commit.message,
});
});
});
},
error: function(reason) {
reject(reason);
}});
};
return Ember.RSVP.hash({
commits: gitactivitiesPromise(),
repos: gitrepositoriesPromise()
});
Template
<ul>
{{#each model.repos}}
<li>{{name}}</li>
{{/each}}
</ul>
<ul>
{{#each model.commits}}
<li>{{message}}</li>
{{/each}}
</ul>
So the problem must be here in
{{#each model.commits}}
<li>{{message}}</li>
{{/each}}
What am i doing wrong? here the jsbin reproducing the issue.
Aucun commentaire:
Enregistrer un commentaire