# setupController method and transient controller

**URL:** <https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517>\
**Category:** Uncategorized\
**Created:** [August 5, 2015, 9:50pm UTC](https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517 "2015-08-05T21:50:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![styleslb](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@styleslb](https://discuss.emberjs.com/u/styleslb)\
**Post date:** [August 5, 2015, 9:50pm UTC](https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517/1 "2015-08-05T21:50:29Z")

</div>

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:

> <https://stackoverflow.com/questions/31842278/ember-setupcontroller-and-transient-controllers>

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [August 6, 2015, 5:26am UTC](https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517/2 "2015-08-06T05:26:37Z")

</div>

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](https://github.com/broerse/ember-cli-blog/blob/master/app/controllers/post.js)

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [August 6, 2015, 6:26am UTC](https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517/3 "2015-08-06T06:26:46Z")

</div>

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!).

```nohighlight
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](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](https://github.com/emberjs/ember.js/blob/ba723a188d84ccc765964830a8bb7c4ae0e7970e/packages/ember-routing/lib/system/route.js#L2111-L2117)

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [August 6, 2015, 6:32am UTC](https://discuss.emberjs.com/t/setupcontroller-method-and-transient-controller/8517/4 "2015-08-06T06:32:49Z")

</div>

Also I reported the bug here: [https://github.com/emberjs/ember.js/issues/11995](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.
