2016-04-26 19 views
1

私はAngularjsアプリケーションを開発しています。 私はocLazyLoadui.routerを使用しています。エラー:ng:areq不正な引数ANGULAR

私はコントローラーと、chart.jsangular-nvd3を使ってグラフを持つ2つのビューを持っています。

グラフィックスが表示されますが、この間違いを与え続け:

Error: ng:areq Bad Argument

angular.js:13550 Error: [ng:areq] http://errors.angularjs.org/1.5.5/ng/areq?p0=ChartCtrl&p1=not%20aNaNunction%2C%20got%20undefined at Error (native)


MY app.js ::

.state('dashboard.chart',{ 
    templateUrl:'views/chart.html', 
    url:'/chart', 
    controller:'ChartCtrl', 
    resolve: { 
     loadMyFile:function($ocLazyLoad) { 
      return $ocLazyLoad.load({ 
       name:'chart.js', 
       files:[ 
       'bower_components/angular-chart.js/dist/angular-chart.min.js', 
       'bower_components/angular-chart.js/dist/angular-chart.css' 
       ] 
      }), 
      $ocLazyLoad.load({ 
       name:'sbAdminApp', 
       files:['scripts/controllers/chartContoller.js'] 
      }) 
     } 
    } 
}) 
.state('dashboard.graficohora',{ 
    templateUrl:'views/graficohora.html', 
    url:'/graficohora', 
    controller:'GraficohoraCtrl', 
    resolve: { 
     loadMyFile:function($ocLazyLoad) { 
      return $ocLazyLoad.load({ 
       name:'nvd3', 
       files:[ 
       'bower_components/d3/d3.js', 
       'bower_components/nvd3/build/nv.d3.js', 
       'bower_components/angular-nvd3/dist/angular-nvd3.js', 
       ] 
      }), 
      $ocLazyLoad.load({ 
       name:'sbAdminApp', 
       files:['scripts/controllers/graficohoraController.js'] 
      }) 
     } 
    } 

MY CONTROLLER ::

angular.module('sbAdminApp') 
    .controller('GraficohoraCtrl', ['$scope', '$timeout', function ($scope, $timeout) { 
     $scope.options = { 
      chart: { 
       type: 'pieChart', 
       height: 500, 
       x: function(d){return d.key;}, 
       y: function(d){return d.y;}, 
       showLabels: true, 
       duration: 500, 
       labelThreshold: 0.01, 
       labelSunbeamLayout: true, 
       legend: { 
        margin: { 
         top: 5, 
         right: 35, 
         bottom: 5, 
         left: 0 
        } 
       } 
      } 
     }; 

     getData() 
     function getData(){ 
      $scope.data = [ 
       { 
        key: "One", 
        y: 5 
       }, 
       { 
        key: "Two", 
        y: 2 
       }, 
       { 
        key: "Three", 
        y: 9 
       }, 
       { 
        key: "Four", 
        y: 7 
       }, 
       { 
        key: "Five", 
        y: 4 
       }, 
       { 
        key: "Six", 
        y: 3 
       }, 
       { 
        key: "Seven", 
        y: .5 
       } 
      ]; 
     } 


    }]); 

MY HTML ::

<div class="row"> 
    <div class="col-lg-12"> 
     <h1 class="page-header">Charts</h1> 
    </div> 
    <!-- /.col-lg-12 --> 
</div> 
<div class="row"> 
    <div class="col-lg-12 col-sm-12" id="polar area-chart" ng-controller="ChartCtrl"> 
     <div class="panel panel-default"> 
      <div class="panel-heading">Informações sobre Dados Analisados</div> 
      <div class="panel-body"> 
       <div ng-controller="ChartCtrl"> 
        <nvd3 options='options' data='data'></nvd3> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 

は、あなたがこのエラーで私を助けてくださいことはできますか? ありがとう..

+0

おそらく、http://stackoverflow.com/questions/33452568/error-ngareq-bad-argumentの複製 – iGbanam

答えて

0

htmlファイルのng-controllerが間違った場所にあり、このエラーが発生しました。

0

あなたのアプリケーションモジュールで 'ChartCtrl'を定義することは決してありません。
これをあなたのアプリモジュールに追加します。

.controller('ChartCtrl',['$scope', function ($scope) { 
    // add functionality to your controller 
}]); 
関連する問題