i have page that contains 3 controller
and i have service that make $http call
after get the object from the http call i want the other controller use the data from the server.
for example my main controller apply the http call and the other controller use the response for the call with no multiple server call.
this is my print screen for the application the "loading" in this page is the main controller but the notify is another controller and the status is another controller. the both controllers need the data from the call
what the best way to apply this call? thanks
my NOT FINISHED CODE
App.factory('siteService', function($http, $location, $q) {
var siteObject = {},defered = $q.defer();
function applaySiteServiceCall() {
$http(req).success($q.resolve);
return defered.promise;
}
return {
applaySiteServiceCall : applaySiteServiceCall,
promise : defered.promise
};
});
App.controller('VerifyController', ['$scope','$sce' ,'siteService', function($scope, $sce, siteService) {
siteService.applaySiteServiceCall().then(function (data) {
siteService.siteObject = data;
ֿֿֿֿ/// needed apply the data in the other controller
});
}]);
//// controller 2
App.controller('AlertController', ['$scope','siteService', function($scope, siteService) {
siteService.siteObject.promise.then(function(data) {
$scope.siteObject = data;
});
}]);