0
votes

I have a Layout where I have a Title area always outside my {{outlet}}. The actual Title depends on the model from my subroute. Thats why I have defined in my setupController hooks something like this:

  var appController =  this.controllerFor('application');
  appController.set('title', model.get('title'));

Problem is, that int that moment the model might not be resolved yet. That is why I would like to create in some cases a Binding from the Title of my model to the appController.

In other cases the Title might be fix. In those cases I wan't to overwrite the binding with a simple set:

  var appController =  this.controllerFor('application');
  appController.set('title', 'Dashboard');

Or are there better ways to access subroute values from outside of the outlet. (Consider that needs might be the wrong approach since otherwise my application controller would need every other controller, and I would not know, which one is active.

1

1 Answers

0
votes

you can create an action in the application route, then use send from any other route/controller to hit that action, then let the action update the controller.

App.FooRoute = Em.Route.extend({
  someFunc: function(){
    this.send('updateFoo', 'blah');
  }
});

App.ApplicationRoute = Em.Route.extend({
  actions: {
    updateFoo: function(value){
      this.controller.set('foo', value);
    }
  }
});