我使用Ember.js屬性「餅圖」和我的bower.json文件是:導致灰燼,圖表無法找到對象
{
"name": "stats-front-end",
"dependencies": {
"handlebars": "~1.3.0",
"jquery": "~2.1.1",
"ember": "1.8.1",
"ember-data": "1.0.0-beta.12",
"ember-resolver": "~0.1.10",
"loader.js": "stefanpenner/loader.js#1.0.1",
"ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
"ember-qunit": "0.1.8",
"ember-qunit-notifications": "0.0.4",
"qunit": "~1.15.0",
"ember-charts": "~0.3.0"
}
}
我想顯示餅圖在我的app/templates/languages/index.hbs
視圖中顯示爲here。該app/templates/languages/index.hbs
目前是這樣的:
<ul>
{{#each}}
<li> {{name}} {{occurences}}</li>
{{else}}
<li>No language found.</li>
{{/each}}
</ul>
<div class="chart-container">
{{pie-chart data=content}}
</div>
如果我刪除我的#each
塊渲染精細圖(從灰燼數據拉)。然而,當我使用在app/controllers/languages/index.js
上發現的控制器來裝飾視圖時,即使沒有從燼數據中提取,我也什麼也得不到。
應用程序/控制器/語言/ index.js
import Ember from 'ember';
export default Ember.ArrayController.extend({
content: [
{
"label": "Equity",
"value": 12935781.176999997
},
{
"label": "Real Assets",
"value": 10475849.276172025
},
{
"label": "Fixed Income",
"value": 8231078.16438347
},
{
"label": "Cash & Cash Equivalent",
"value": 5403418.115000006
},
{
"label": "Hedge Fund",
"value": 1621341.246006786
},
{
"label": "Private Equity",
"value": 1574677.59
}
]
});
控制檯上寫着:
Uncaught Error: <[email protected]:default::ember426> Handlebars error: Could not find property 'pie-chart' on object <[email protected]:languages/index::ember418>.
我試過語法的變化,讓餅圖到沒有成功的看法。理想情況下,我希望根據我在燼數據中創建的餅圖來創建餅圖,但是現在只需要渲染一些內容即可。
該項目是開源和發現here
感謝薩姆!如果我刪除了「{{餅圖數據=內容}}」,那麼該頁面可以正常加載存儲在我的模型中的數據(不是我上面引用的手動數據)。 Ramy的回答雖然有所幫助,但仍然存在同樣的問題,儘管我在'vendor.js'中看到'Ember.Handlebars.helper('pie-chart',Ember.Charts.PieComponent);' – Anthony 2014-12-06 21:55:59