How to Share data to all controller?
I have a controller that pull data from server(file.json) that i want to share to other controller
sampleApp.controller('PhoneListCtrl',
['$scope', '$http',
function($scope, $http) {
$http.get('App_Data/phonelist.json').
success(function(returnDataFrmJson){
$scope.phonesScope = returnDataFrmJson;
});
}]);
controller that will access the shared data of the first one
sampleApp.controller('AddIPhoneController',
['$scope', '$http',
function($scope, $http) {
$scope.newInput= 'sample text';
$scope.sharedText= dataFromSharedControll;
}]);
the html file that will show the data.
{{newInput}} {{sharedText}}