app.factory('dataPassingService', function() {
var savedData = {};
function set(data) {
savedData = data;
}
function get() {
return savedData;
}
return {
set: set,
get: get
}
});
controller1
$scope.text = '9';
dataPassingService.set($scope.text);
controller2
$scope.mes = dataPassingService.get();
alert("the scope is "+scope.mes);
I pass the $scope.text from controller1 to controller 2 using app.factory and it work perfect. i would like to pass more scopes together from controller1 to controller2 for example i would like to pass $scope.text='9' and scope.text1='10' and then with the take it to the controller2 with datapassingService.get().Thanks in advance