Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Whilst the solution is simple, let me try and explain it. Please feel free to ask any questions if you're unsure.</p> <p>You've bound to a property on an <strong>instance</strong> of <code>App.indexController</code>. However, this instance doesn't exist, because Ember.JS no longer places the instance of the controllers directly on <code>App</code>.</p> <p><em>It used to reside on <code>App</code> in previous versions of Ember, but not any more, because it's bad practice to reference a controller using its absolute name, since it creates <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29">tight coupling</a> between the controllers.</em></p> <p>That's why Ember.JS have other ways to reference to controllers. It is a common requirement to need other controllers in your current controller. Ember.JS have the following methods:</p> <ul> <li><code>this.controllerFor()</code> in <code>Ember.Route</code>: <a href="http://emberjs.com/guides/routing/setting-up-a-controller/">http://emberjs.com/guides/routing/setting-up-a-controller/</a></li> <li><strong>However, controllerFor has now been deprecated in favour of:</strong></li> <li><code>needs</code> which tells the current controller which controllers it needs access to: <a href="https://github.com/emberjs/ember.js/pull/1731">https://github.com/emberjs/ember.js/pull/1731</a></li> </ul> <p>Therefore, if we implement the <code>needs</code>, then your controller now has access to the other controller, as well as the properties it possesses: <a href="http://jsfiddle.net/uB5tX/7/">http://jsfiddle.net/uB5tX/7/</a></p> <p>By using the <code>needs</code>, we have loosely coupled the controllers. We have referenced it by its name, and Ember.JS will look-up the controller for us. If we change <code>App</code> then we won't need to change anything, and if/when Ember.JS changes the behaviour of controllers, we shouldn't need to update our <code>needs</code> again, because when the behaviour changes, then the <code>needs</code> will also update, bringing back the correct controller.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload