So, I have a set of objects on the server that I want to populate ng-repeat when the page loads.
I had a factory done that retrieved the list from a resource on the server, for example:
app.factory('objectArray', ['$http', function($http) { // This is returning a $$state object // instead of response.data... return $http.post('/get_collection').then(function(response) { console.log(response.data); return response.data; }); }]);
I had this code before when using ui-router and the resolve property in the status declaration. However, when I enter this factory directly into my controller, instead of receiving response.data, I get a $$ state object.
My controller is as follows:
app.controller('applicationController', ['$scope', 'objectArray', function($scope, objectArray) { $scope.array = objectArray; console.log($scope.array); }]);
angularjs state factory
Alex turner
source share