Hi All: 

 

There is something I do not understand  in the following code: 

 

Why is executed first point A) and then B)?

 

"use strict";

var cUrl = ' <http://localhost:3000/> http://localhost:3000'

 

google.setOnLoadCallback(function () {  

   angular.bootstrap(document.body, ['my-app']);

});

google.load('visualization', '1', {packages: ['corechart']});

 

var myApp = myApp || angular.module("my-app",["google-chart"]);

 

myApp.controller("IndexCtrl", function($scope, $http){  

   $scope.data = [];

   $scope.data1 = {};

   $scope.data1.dataTable = new google.visualization.DataTable();

   $scope.data1.dataTable.addColumn("string","Periodo");

   $scope.data1.dataTable.addColumn("number","Total");

 

   $http({url: cUrl + '/api/pagosporperiodo/', method: 'GET'})

       .success(function (data, status, headers, config) {

               $scope.data = data;

 

               /* B) This is done later when the chart is now drawn in the
browser. */

 

               for (var i = 0; i < $scope.data.length; i++) {

                   $scope.data1.dataTable.addRow([$scope.data[i].Periodo,
$scope.data[i].TotalIngresado]);

               };                

           })

 

   /* A) This run first */

 

   var data = [

   {"Periodo": "201006", "TotalIngresado": 147770.5    },

   {"Periodo": "201007", "TotalIngresado": 107587.87    },

   {"Periodo": "201008", "TotalIngresado": 1179121.31    }]

 

   $scope.data1.dataTable.addRow([data[0].Periodo,data[0].TotalIngresado]);

   $scope.data1.dataTable.addRow([data[1].Periodo,data[1].TotalIngresado]);

   $scope.data1.dataTable.addRow([data[2].Periodo,data[2].TotalIngresado]);


});

 

Thanks in advance!

 

 





-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to