mardi 7 juillet 2015

How to create a controller property that updates when a service property changes

Using Ember 1.13

I may be missing something and going about this in the totally wrong way.

I have session state saved in an ember service that is available to all my controllers. It has a boolean property isExistingSession.

In the header of my app I want to conditionally display a login button or user info depending on the value of isExistingSession.

As far as I know I can't use the service property directly in my handlebar so my solution was to create a computed property on the applicationController that always equals the value of of isExistingSession on the sessionService

export default Ember.Controller.extend({
  isExistingSession: function () {
    return sessionService.get('isExistingSession');
  }.property('sessionService.isExistingSession'),

But the computing the property off of an outside entity seems to be invalid.

Any idea on how to accomplish this?




Aucun commentaire:

Enregistrer un commentaire