How can I access values returned from service using controller. In my code service.js function showInfo() returns JSON objects. But I cannot access these objects outside this function. If I try to do console.log from controller.js
console.log(chartService.showInfo.new_data)
I get
error Cannot read property 'new_data' of undefined.
Same happens if I try to
console.log(chartService.showInfo)
I get undefined.
How can I access the JSON object new_data inside function showInfo from the controller?
Service.js
angular.module('myApp')
   .service('chartService', function (){
  return {
     getUrl: function init(path) {
        Tabletop.init( { key: path,
                         callback: showInfo,
                         simpleSheet: true } )
     }
  }
     function showInfo(data, tabletop){
          var new_data = JSON.stringify(data.map(function(el) {
            return {
                "name": el[Object.keys(el)[0]],
                "y": +el[Object.keys(el)[1]]
            };
     }));
   }
})
Controller.js
angular.module('myApp')    
      .controller('piechartCtrl', [ '$scope', 'chartService',  function (chartService, $scope) {
        console.log(chartService.showInfo.new_data)
    
    }]);
 
     
     
     
    