I have an ember component expecting a parameter as an array of objects. By default, this parameter is gonna be a native array with native objects inside. I'd like to transform this array into an ember array containing ember objects.
I was thinking about something like that, but this will create an infinite loop firing the observer every time:
export default Ember.Component.extend({
content: null,
contentDidChange: function () {
var content = Ember.A();
this.get('content').forEach(function (item) {
content.addObject((item.constructor.toString() !== 'Ember.Object') ? Ember.Object.create(item) : item);
});
this.set('content', content);
}.observes('content'),
});
What is the best practise to do that?
Thanks
Aucun commentaire:
Enregistrer un commentaire