2016-08-11 2 views
0

** 컨트롤러 코드 구글 차트 : **인수는 숫자 나 배열이어야합니다 -

  $http({method: 'GET', 
       url: '/proj_prof_table', 
       params: {id: id} 
      }).success(function(response) 
      { 

      $scope.data = response; 

      $scope.emp_id = []; 
      $scope.emp_name = []; 
      $scope.billing_status = []; 
      $scope.mgr = []; 
      $scope.mgr_id = []; 
      $scope.stdt = []; 
      for(i in $scope.data) 
       { 
        $scope.emp_id.push($scope.data[i].Emp_ID); 
        $scope.emp_name.push($scope.data[i].Emp_Name); 
        $scope.billing_status.push($scope.data[i].Billing_Status); 
        $scope.mgr.push($scope.data[i].Manager); 
        $scope.mgr_id.push($scope.data[i].Mgr_ID); 
        $scope.stdt.push($scope.data[i].Start_Date); 
       } 
      }); 
     // Get client timeline 
     // Prepare Data 
    $http({method: 'GET', 
       url: '/proj_prof_client_timeline', 
       params: {id: clid} 
      }).success(function(response) 
      { 

      $scope.data = response; 
      alert($scope.data); 
      $scope.project = []; 
      $scope.stdt = []; 
      $scope.endt = []; 
      $scope.x = []; 
      for(i in $scope.data) 
       { 
        $scope.x[i] = []; 
        $scope.x[i].push($scope.data[i].Proj_Name); 
        $scope.x[i].push($scope.data[i].Start_Date); 
        $scope.x[i].push($scope.data[i].End_Date); 
       } 

       alert($scope.x[0]); 
      }); 

     drawChart($scope.x); 

} 


    //time line chart 
    google.charts.load('current', {'packages':['timeline']}); 
    google.charts.setOnLoadCallback(drawChart); 
    function drawChart(param) { 


    //Chart code 
    var container = document.getElementById('timeline'); 
    var chart = new google.visualization.Timeline(container); 
    var dataTable = new google.visualization.DataTable(); 

    dataTable.addColumn({ type: 'string', id: 'Projects' }); 
    dataTable.addColumn({ type: 'date', id: 'Start' }); 
    dataTable.addColumn({ type: 'date', id: 'End' }); 
    dataTable.addRows(param); 

    chart.draw(dataTable); 
    } 
위의 코드 "했던 addRows에게 주어진 인수는 숫자 나 배열이어야합니다"던졌습니다

은 $ scope.x 외에 [내가 [ELE, ELE, ELE] [ELE, ELE, ELE]로 $ scope.x을 정의 할 수있는 방법 anyother 2D 어레이

있는가 되 ele, ele, ele]] 배열을 매개 변수로 전달하여 addrows()

답변

0

var app = angular.module("myApp", []); 
 
app.controller("myCtrl", function($scope) { 
 
\t $scope.emplist = [ 
 
\t     {empname:'samudrala',empsalary:'4.5 - pam',empid:'Emp - 450'}, 
 
\t     {empname:'soujanya',empsalary:'4.5 - pam',empid:'Emp - 451'}, 
 
\t     {empname:'jai',empsalary:'4.5 - pam',empid:'Emp - 455'}, 
 
\t    
 
\t     {empname:'Raamu',empsalary:'4.5 - pam',empid:'Emp - 459'} 
 
\t     ]; 
 
\t \t $scope.addItem = function(){ 
 
\t \t $scope.emplist.push({'empname':$scope.empname,'empsalary':$scope.empsalary,'empid':$scope.empid}); 
 
\t \t $scope.empname = ''; 
 
\t \t $scope.empsalary = ''; 
 
\t \t $scope.empid = ''; 
 
\t } 
 
\t $scope.remItem = function(item){ 
 
\t \t $scope.emplist.splice(item,1); 
 
\t \t } 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div ng-app="myApp" ng-controller="myCtrl"> 
 
<table style="width:100%;"> 
 
<tr height="25" style=" background: #99ff00;"> 
 
<th width="5%"></th> 
 
<th width="40%">EMP Name</th> 
 
<th width="30%">EMP Salary</th> 
 
<th width="">EMP ID</th> 
 
<th width=""></th> 
 
</tr> 
 
<tr height="25" ng-repeat="x in emplist"> 
 
<td style="text-align: center;">{{$index}}</td> 
 

 
<td style="text-align: center; ">{{x.empname}}</td> 
 

 
<td style="text-align: center;">{{x.empsalary}}</td> 
 

 
<td style="text-align: center;">{{x.empid}}</td> 
 

 
<td style="text-align: center;"><button ng-click="remItem($index);" style="background:#00ffff; border:0px;">&times; Remove</button></td> 
 

 
</tr> 
 
<tr height="25"> 
 
<td><button ng-click="addItem();" style="background: #00ffff; border:0px; width:100%; height:100%;">Add</button></td> 
 
<td style="padding:2px;"><input type="text" ng-model="empname" style="width:100%;" ></td> 
 
<td style="padding:2px;"><input type="text" ng-model="empsalary" style="width:100%;" ></td> 
 
<td style="padding:2px;"><input type="text" ng-model="empid" style="width:100%;" ></td> 
 
</tr> 
 
</table> 
 
</div>

관련 문제