I need to pass data from modal to another page, My modal promise function like this,
modalInstance.result.then(function (product) {
$scope.selectedProduct = product;
$location.path('cart');
});
Note that, Here I need to send product data to the new page 'cart'. How can I do this?
app.serivce('commonService',
function(){
this.sharedData = 'Shared Data';
this.getSharedData = function(){
return this.sharedData;
};
this.updateSharedData = function(updatedData){
this.sharedData = updatedData;
};
}
);
app.controller('ctr1', ['$scope', 'commonService',
function($scope, commonService){
// Call this function from modal to update sharedData
$scope.updateData = function(newData){
commonService.updateSharedData(newData);
};
}
]);
app.controller('ctr2', ['$scope', 'commonService',
function($scope, commonService){
// Call this function to retrieve sharedData
$scope.loadSharedData = function(){
commonService.getSharedData();
};
}
]);