I'm trying to manipulate data inside a modal in AngularJS and after that, view it outside of the modal. So I have to pass the data from the inner controller (which is used by the modal) to the outer controller.
To put the data into the inner controller from the outer one I've done this with help of the option resolve of $modal.open :
myApp.controller('MyCtrl', function ($scope, $modal) {
$scope.number = 1;
$scope.openModal = function () {
$modal.open({
templateUrl: 'myModalContent.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, number) {
$scope.number = number;
$scope.submit = function () {
//How to iterate var number in the outer controller?
//$scope.number++;
$modalInstance.dismiss('cancel');
}
},
resolve: {
number: function () {
return $scope.number;
}
}
});
};
});
Now I want to count number up in the modal and show it outside of the modal. $scope.number affects obviously just the number in the current controller, so how can I set the variable of the outer controller?
Here's my Fiddle.
Your help would be appreciated.