我在這裏錯過了什麼嗎?兩天來,我仔細查看了這段代碼,看看剛開始的問題。我正在測試Chart Js插件,我打算使用它。圖表Js + Angular
似乎有一些與我的代碼衝突,dosent讓任何腳本運行。請幫助
//Charts//
// Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext("2d");
var LineChart = new Chart(ctx).Line(data);
//Data//
data = {
labels : ["January", "February", "March", "April", "May", "June", "July"],
datasets : [{
data:[65, 59, 80, 81, 56, 55, 40]
}]
};
var app = angular.module('myApp',[]);
app.controller('MainController', function($scope){
$scope.Title = 'My Charts';
});
http://plnkr.co/edit/RXzjPllg0RSWjvgMjIoU?p=preview
感謝@Yuujin,必須爲聊天代碼放在內MainController? –
沒問題,將數據放入工廠/服務可能會更好,並且在應用程序啓動時在.run函數中添加var ctx/LineChart –