mardi 8 mars 2016

Grouping multiple models to iterate over in Ember CLI

I am trying to follow along with this older stack overflow question in Ember 2.3, but the syntax has been deprecated. Is there anyway I can group several types of models into a single object to iterate over(like a tumblr style dashboard) over in one template in Ember 2.0+?

Original question:

stream: function() {
var post = this.get('post'),
    bookmark = this.get('bookmark'),
    photo = this.get('photo');

var stream = [];

stream.pushObjects(post);
stream.pushObjects(bookmark);
stream.pushObjects(photo);
return stream;

}.property('post.@each', 'bookmark.@each', 'photo.@each'),

My attempt:

stream: Ember.computed('post.[]', 'bookmark.[]', 'photo.[]', function() {
var post = this.get('post');
var bookmark = this.get('bookmark');
var photo = this.get('photo');

var stream = [];

stream.pushObjects(post);
stream.pushObjects(book);
stream.pushObjects(photo);    
return stream;
}),




Aucun commentaire:

Enregistrer un commentaire