jeudi 24 mars 2016

In Ember setup a computed on the controller but from within setupController in a route

My application only has an application route, it manages to do without an explicit controller file. Infact I have no controller files at all, and want to keep it that way.

In my application route I setup a couple defaults in the controller that are used in the application template:

setupController(controller, model) {
  this._super(controller, model);

  controller.set('session', Ember.inject.service('session'));
  controller.set('environmentName', ENV.environment);
},

I now want a computed that will respond to two different variables changing. These variables will change in actions that bubble up to the application route.

So say they are foo and bar, a computed on the route itself would be.

someComputed: Ember.computed('foo', 'bar', function() {
  let result = '';
  // logic involving foo and bar
  return result;
}),

The problem is that this is not available in the application template. How can I 'register' the computed with the controller in a better way, and respond to application route actions changing foo and bar?




Aucun commentaire:

Enregistrer un commentaire