I use a service to request data, then the service is injected into a component. Data is retrieved from Ember Mirage.
My problem is that I can't display the data as a property, even though when this property is used in computedProperty, the computedProperty correctly computes and displays.
Component template in Emblem:
.notifications-number
each notificationService.notifications.content as |notification|
span
Notification service:
import Ember from 'ember';
export default Ember.Service.extend({
store: Ember.inject.service('store'),
// render bugs out
notifications: function() {
return this.get('store').findAll('notification')
}.property(),
// renders correctly
countUnread: function() {
return DS.PromiseObject.create({
promise: this.get('notifications').then((notifications) => {
return notifications.get('length')
})
});
}.property(),
});
I have similar problem with another service and component where retrieved data is not an array but an object.
- renders
<(subclass of Ember.ObjectProxy):ember404>
- renders
<my-app@model:myModel::ember580:1>
- renders nothing.
Everything worked fine when I manually set values in store on app init, but doesn't work when actual asynchronous requests are sent to API mock.
Aucun commentaire:
Enregistrer un commentaire