I have component with a couple of properties, using a promise in the willRender hook to try and create (pagination) object:
export default Ember.Component.extend({
pagination:null,
testing:null // to check if this.set is ok within the promise!
willRender() {
let page = {};
let model = this.get('data');
model.get('products').then(relatedItems => {
relatedItems.forEach(function(item,index) {
// set up the page object here, omitted for brevity
});
this.set('testing','hello world');
console.log(this.get('testing')); // hello world
this.set('pagination',page);
console.log(this.get('pagination')); // Object {Prev: "product-1", Next: "product-2"}
},reject => {
console.log('error '+reject);
});
}
})
In my template
// prints hello world
However, if I try and access eg , the browser crashes with a loop printing out the object to the console.
I don't know where I'm going wrong here - any help much appreciated!
Aucun commentaire:
Enregistrer un commentaire