Can I calculate a property from the service I entered?

I have an isAuthenticated property in a service that is currently being entered on my application route, how can I calculate the property from the entered service on my route?

export default Ember.Route.extend({
    session : Ember.inject.service('market-session'),
    isUser : Ember.computed.oneWay('session.IsAuthenticated'),
}

Is it possible? The template cannot get the value.

Inside the template -

{{#if isUser}}
   User is authenticated
{{else}}
   User log in form
{{/if}}

This computed property only works if I transfer it to the controller, should it work both on the route and on the controller? Did I miss something?

+4
source share
1 answer

After the service has been introduced, you can access the calculated properties of the service exactly as shown above. From the Ember docs:

, . , .

, , .

+2

All Articles