How to access a property in an itemController via the needs API in Ember.js -
how can access properties of itemcontroller when i'm accessing content of controller via needs api?
app.postsindexcontroller = ember.arraycontroller.extend itemcontroller: 'post' someaction: -> console.log("i'm melting!") app.postcontroller = ember.objectcontroller.extend somecomputedproperty: (-> true ).property() app.indexcontroller = ember.controller.extend needs: ['postsindex'] <script type="text/x-handlebars" data-template-name="index"> {{#each post in controllers.postsindex.content}} {{somecomputedproperty}} <a {{action someaction target="postsindex"}}>click</a> {{/each}} </script> i tried {{controllers.postsindex.somecomputedproperty}} , {{somecomputedproperty}} in index template.
how can access properties of itemcontroller when i'm accessing content of controller via needs api?
first should pass controllers.postsindex {{each}} helper instead of controllers.postsindex.content. otherwise {{each}} helper looping on model objects without going thru postsindexcontroller. @milkywayjoe suggested, try like:
<script type="text/x-handlebars" data-template-name="index"> {{#each post in controllers.postsindex}} {{somecomputedproperty}} <a {{action someaction target="postsindex"}}>click</a> {{/each}} </script> i tried that, seems somecomputedproperty doesn't update when changes, although calculates correctly on page load.
ember computed properties don't update unless specify list of dependencies:
app.postcontroller = ember.objectcontroller.extend somecomputedproperty: (-> true ).property('title', 'someotherproperty', 'etc')
Comments
Post a Comment