Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seems similar to what I've seen in todomvc.com: <a href="https://github.com/addyosmani/todomvc/blob/gh-pages/architecture-examples/emberjs/js/controllers/todos_controller.js#L32" rel="nofollow">https://github.com/addyosmani/todomvc/blob/gh-pages/architecture-examples/emberjs/js/controllers/todos_controller.js#L32</a></p> <p>Assuming you have an ArrayController that displays all Devices, here is what I would try:</p> <ul> <li>create a computed property on the ArrayController for Devices that computes the total, and depends on <code>@each.measure</code>;</li> <li>(implying that Device would be displayed by a sub-view pointing to its own ObjectController) add <code>needs: ['devices']</code> to the declaration child controller, to indicate that this controller depends on the Devices controller;</li> <li>create a computed property on the Device controller that computes the share, and depends on <code>measure</code> and <code>controllers.devices.total</code>.</li> </ul> <p>Then in the share() property function on the Device controller you can get a reference to the instance of the parent controller by using <code>this.get('controllers.devices')</code>, or you can even get the value of the total property directly with <code>this.get('controllers.devices.total')</code>.</p> <hr> <p>I originally started the answer with "I haven't tried it myself", but since I also wanted to see if this would work, here is a JSBin with working code: <a href="http://jsbin.com/ajoqak/12/edit" rel="nofollow">http://jsbin.com/ajoqak/12/edit</a> (edited to make it work with a REST adapter).</p> <p>Note that this assumes Ember.js 1.0.0-rc2 and a build of ember-data that I made some days ago (there are no official releases yet); the API has changed a bit from some answers/examples that I've seen using previous versions.</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.
    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