I need to use a scope , that is in a controller, in another controller . So I've used a factory :
app.factory('myservice',function(){
var mydata=[];
function set(data){
mydata=data;
}
function get(){
return mydata;
}
return {
set:set,
get:get
}
});
Then In the controller that contains the scope I need I set the data :
myservice.set($scope.value)
In the other controller where I need the scope I get it from the factory :
$scope.value= myservice.get()
This seems to work fine . My problem is that when I refresh the page where I'm using the second controller $scope.value
becomes undefined .
How to fix this ??