I am having similar factory with $http call inside like following:
appModule = angular.module('appModule', []);
appModule.factory('Search', function($rootScope, $http) {
var Search;
Search = {};
Search.types: ["bacon"];
Search.pastEvents = null;
$http.get('api/highlights').success(function(response) {
return Search.pastEvents = response.data;
});
return Search;
});
var notes_module = angular.module('notes', []);
notes_module.config(['$routeProvider', function ($routeProvider) {
var notes_promise = ['Notes', '$route', 'Search', function (Notes, $route, Search) {
//suspect that Search not having pastEvents ready in time of calling index method
//Notes resource
return Notes.index({subject_id: 1 }, Search);
}];
$routeProvider.when('/notes', {
templateUrl:'index.tpl.html',
controller:'NotesCtrl',
resolve:{
notes: notes_promise,
}
});
}]);
Should i care about when data from $http call is ready and when this factory is initialized/injected? Will pastEvents be ready? If i should care how do i do?
I suspect that Search object not having pastEvents ready in time of calling index method of Notes resource.