javascript
  • angularjs
  • 2017-06-01 178 views 0 likes 
    0

    我試圖讓this piechar工作。 這裏是我的代碼來繪製簡單的餅圖嘗試獲取工作狀態時出現角度錯誤

    <html ng-app="chartApp"> 
        <head> 
        <link rel="stylesheet" type="text/css" href="css/style.css"> 
        <link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'> 
    
        <!-- angular --> 
        <script type="text/javascript" src="https://code.angularjs.org/1.4.1/angular.min.js"></script> 
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script> 
    
        <!-- fusioncharts core --> 
        <script type="text/javascript" src="js/fusioncharts.js"></script> 
        <script type="text/javascript" src="js/fusioncharts.charts.js"></script> 
    
        <!-- angular plugin --> 
        <script type="text/javascript" src="js/angular-fusioncharts.min.js"></script> 
    
        <!-- zune theme --> 
        <script type="text/javascript" src="js/zune-theme.js"></script> 
    
        <script type="text/javascript"> 
    
        var pieChart = angular.module("pieChart", ["ng-fusioncharts"]); 
    
    // controller for chart 
    pieChart.controller("chartController", function($scope) { 
    
        $scope.myDataSource = { 
        chart: { 
         caption: "Age profile of website visitors", 
         subcaption: "Last Year", 
         startingangle: "120", 
         showlabels: "0", 
         showlegend: "1", 
         enablemultislicing: "0", 
         slicingdistance: "15", 
         showpercentvalues: "1", 
         showpercentintooltip: "0", 
         plottooltext: "Age group : $label Total visit : $datavalue", 
         theme: "fint" 
        }, 
        data: [ 
         { 
          label: "Teenage", 
          value: "1250400" 
         }, 
         { 
          label: "Adult", 
          value: "1463300" 
         }, 
         { 
          label: "Mid-age", 
          value: "1050700" 
         }, 
         { 
          label: "Senior", 
          value: "491000" 
         } 
        ] 
    }}); 
        </script> 
        </head> 
        <body> 
        <center> 
         <div ng-controller="chartController"> 
         <fusioncharts 
        width="600" 
        height="400" 
        type="pie3d" 
        datasource="{{myDataSource}}" 
    ></fusioncharts> 
        </div> 
        </center> 
    </body> 
    </html> 
    

    我得到這個錯誤

    angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.1/$injector/modulerr?p0=chartApp&p1=Error%3…0zc%20(https%3A%2F%2Fcode.angularjs.org%2F1.4.1%2Fangular.min.js%3A20%3A30) 
    

    回答

    0

    angular.module被設置爲「餅圖」,但你的ng-app指令設置爲chartApp(該指令應放在在body而不是html也)...所以Angular不知道該怎麼引導。嘗試使用angular.module("chartApp", ...)並將ng-app指令放在您的「身體」標記上。

    相關問題