Change your console to console.log(myTest,myTest);
On Tue, Mar 15, 2016 at 1:51 PM, <[email protected]> wrote: > I am new to Angular and have created a factory for the reading of a > standard json file. > My controller fires the factory successful but at some point my json array > is transformed into an Object and i can't figure out why? > > I tried many forum solutions from the web, but none worked as expected. > > var jamboApp = angular.module('jambo', ['ngResource']) > > .factory('jamboFactory',['$resource',function($resource){ > return $resource('customers.php', {}, { > query: {method:'GET', isArray:false } > }); > }]) > > .controller('jamboCtrl', function($scope,jamboFactory) { > var myTest= jamboFactory.query(function(data){ > console.log(data); // output: m { thedata=[336], $promise=d, > $resolved=true, more...} > console.log(data.thedata); // output: [[1167692400000, 61.05], > [1167778800000, 58.32], [1167865200000, 57.35], [1167951600000, 56.31]] > return data.thedata; > }); > console.log('myTest here is:'+myTest); // output: myTest here > is:[object Object] > console.log('myTest here is:'+myTest.thedata); //output: myTest here > is:undefined > $scope.chartData=myTest; > console.log('chartdata here is:'+$scope.chartData.toSource()); // > output: chartdata here is:({$promise:{$$state:{status:0}}, $resolved:false}) > > .......... /// rest of my controller > > }) > > > =================================================================================== > Customers.php contains a basic json set: > > {"thedata":[[1167692400000, 61.05], [1167778800000, 58.32], > [1167865200000, 57.35], [1167951600000, 56.31]]} > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- Thanks and Regards, *Kiran A* -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
