Im currently messing around learning Angular. I have a controller thats hooked up to a radial progress bubble, i am creating a factory that uses $http to grab some dummy data from data.json I inject the factory into my controller and set that data into a variable so i can use it inside some other objects. To be exact, i want to take the first element of the returned array from my json file as the dashOffset property on the circle object. The current console.log inside my controller prints Undefined but the console.log in my factory prints out the correct array.
var app = angular.module('app',['ui.router']) .factory('Data', function($http){ return { getData : function(callback){ $http.get('data.json').success(function(res){ console.log(res) }); } } }) .controller('radial', function($scope, Data){ $scope.ryan = Data.getData(); console.log($scope.ryan); $scope.circle = { size : 110, stroke : '#2C3E50', strokeWidth : 10, radius : 48, dashArray : Math.PI * 2 * 48, dashOffset : (Math.PI * 2 * 48) } $scope.circleBG = { size : 110, stroke : '#2C3E50', strokeWidth : 10, radius : 48, dashArray : Math.PI * 2 * 48, dashOffset : (Math.PI * 2 * 48) } });