setupController method and transient controller

I’m trying to use setupController method in the route to pass some data to the controller.

import Ember from 'ember';

export default Ember.Route.extend({
  setupController: function(controller,model) {
    this._super(controller,model);
    controller.var1 = "Variable 1";
  }
});

But the above doesn’t work if the controller isn’t a singleton. Is this by design?

SO question with some more information and twiddle link:

I don’t have the perfect code but it gets the data from the posts controller. If all posts have the same author it does not do this again if you click trough the posts. I like to improve this code and remove the needs:.

https://github.com/broerse/ember-cli-blog/blob/master/app/controllers/post.js

This appears to be an actual bug, since the instance of the controller is different from the instance you have in setupController and the one backing the view.

A workaround would be overriding the renderTemplate hook on your route to pass the instance of the controller versus a string reference which is looked up by default (and creating a new instance of the controller!).

export default Ember.Route.extend({
  setupController(controller, model) {
    this._super(...arguments);
    controller.set('var1', 'foo');
  },
  renderTemplate(controller, model) {
    // note: don't call super here
    this.render('application', {
      controller: controller,
      model: model
    });
  }
});

Where I believe the bug is: https://github.com/emberjs/ember.js/blob/ba723a188d84ccc765964830a8bb7c4ae0e7970e/packages/ember-routing/lib/system/route.js#L1820

It’s not passing the instance of the controller, instead it’s forced to take a different code path and generates a new controller: https://github.com/emberjs/ember.js/blob/ba723a188d84ccc765964830a8bb7c4ae0e7970e/packages/ember-routing/lib/system/route.js#L2111-L2117

Also I reported the bug here: https://github.com/emberjs/ember.js/issues/11995

My workaround will suffice though until a fix lands. It’s possible it won’t be fixed though given the focus to move towards routeable components.