I was trying to get some data from a server using Angular Factory and use it in Directive to draw some chart and the code looks like:
ChartApp.directive('hcPie', function (getGlucoseProfileReport) {
function link (scope, element, attrs) {
getGlucoseProfileReport.getGlucoseProfileReport().success(function(response) {
scope.glucoseProfile = response.jData;
console.log(scope.glucoseProfile);
});
console.log(scope.glucoseProfile);
The first console displays the data as needed but the second one logs out undefined. So I am unable to use the data at a global scale. I would really appreciate your help or incite