1
我使用can.Component
在頁面上顯示JSON。如何從json獲取額外信息?
can.Component.extend({
tag: "some-app",
scope: {
items: new Items.List({}),
displayedItems: function() {
...
return items;
}
},
helpers: {
...
},
events: {
"{Items} created": function (Items, ev, newItem) {
...
}
}
})
我怎樣才能得到接收JSON(下)的範圍或助手的「meta」部分?
{
"data": [
{
"description": "Some text",
"id": 1,
"measurement": "pcs",
"name": "Name of item",
"resource_uri": "/api/v1/item/1/"
},
{....}, {....}
}
],
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 3
}
}
我可以Items.findAll().then(function(info){console.log(info.attr('meta'))})
得到它的控制檯,但我在小白(CAN)js和無法理解如何讓它在我需要的地方。