I am using a factory to share data between multiple controllers, here is my factory
var szGetData = "some url that works";
myApp.factory('Data', function ($http) {
var eventData = {};
eventData.getEvent = function (event) {
return $http.get(szGetData, event);
}
return eventData;
});
In my controllers I call the factory the same way for each one as follows:
Data.getEvent()
.success(function (event) {
$scope.eventData = event;
})
.error(function (error) {
$scope.status = 'Unable to load customer data: ' + error.message;
});
This all works and I get the data but it calls my web-service three times and each controller has its own copy of the data. I would like to have the controllers working of the same data and only call the web-service once. thanks for your suggestions.