mardi 1 décembre 2015

Accessing a property from a service in a template

I have a user service that manages reading data from localstorage, it has a property that reads from the local storage a certain object property, the service is setup like so

import Ember from 'ember';
import LocalUser from 'bidr/models/user-local';

const {
  computed: {
    alias
  }
} = Ember;

export default Ember.Service.extend({
  localUser: LocalUser.create(),
  user_id: alias('localUser.user.id'),
  active_auction: alias('localUser.user.active_auction')
});

In my route.js file for my item route I inject the service like so

user: Ember.inject.service('user'),

And in the template I'm attempting to access it like so

{{user.active_auction}}

I was under the impression I could do that but is that not the case? Do I need to set a property on the item route that is equal to the service property to make this work?




Aucun commentaire:

Enregistrer un commentaire