Note that there are some explanatory texts on larger screens.

plurals
  1. POFailed to implement computed property in emberjs
    primarykey
    data
    text
    <p>My fixture data contains multiple array.Out of this multiple array <code>cart_items</code> contains some product data.</p> <p></p> <p>I am trying to calculate total no of products available in cart data (based on length of <code>cart_items</code> items) but i am not able to calculate no of items are present in <code>cart_items</code>.</p> <p></p> <p>In router i have selected application fixture as model for current route,as follow :</p> <pre><code> Astcart.IndexRoute = Ember.Route.extend({ model: function() { return Astcart.Application.find(); } }); </code></pre> <p></p> <p>Computed property code : </p> <pre><code>Astcart.IndexController = Ember.ArrayController.extend({ tot_cart_prd: function() { return this.get("model.cart_items").get('length'); }.property("@each.isLoaded") }); </code></pre> <p>And my fixture data is :</p> <pre><code>Astcart.Application.adapter = Ember.FixtureAdapter.create(); Astcart.Application.FIXTURES = [ { "logo_url": "img/logo.jpg", "logged_in": { "logged": true, "username": "sachin", "account_id": "4214" }, "category_list": [ { "id": "1", "name": "Mobiles &amp; Accessories" }, { "id": "2", "name": "Computers &amp; Software" }, { "id": "3", "name": "Fashion" }, { "id": "4", "name": "Electronics" }, { "id": "5", "name": "Watches &amp; Jewelry" }, { "id": "6", "name": "Health &amp; Beauty" }, { "id": "7", "name": "Games" }, { "id": "8", "name": "Books &amp; Entertainment" }, { "id": "9", "name": "Gaming" }, { "id": "10", "name": "Shoes &amp; Bags" } ], "cart_items": [ { "id": "1", "name": "Samsung Galaxy Tab 2", "qty": "1", "price": "1245.12", "subtotal": "7842.23" }, { "id": "2", "name": "Samsung Galaxy Tab 2", "qty": "1", "price": "1245.12", "subtotal": "7842.23" }, { "id": "3", "name": "Samsung Galaxy Tab 2", "qty": "1", "price": "1245.12", "subtotal": "7842.23" } ] } ]; </code></pre> <p>I have posted my code <a href="http://jsfiddle.net/sachin1989/8SEvk/1/" rel="nofollow">here(JSFiddle)</a>.</p> <p>Can any one tell me why <code>this.get("model.cart_items")</code> is returning null?</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. 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