Problem Summary
I want to invoke getCost function present in main controller, from modal controller.
Pseudo-Code for this to explain the problem follows.
I am am opening modal dialog as follows:
....
//I want to invoke this getCost function from the Modal Controller
//So i pass it via 'resolve'
$scope.getCost = function() {
return i*x+y;//calculates and returns some cost
}
$modal.open({
templateUrl: '/html/MyModal.html',
controller: MyModalCtrl,
resolve: {
getCostNow: function () {
return $scope.getCost;
}
}
});
.....
And in MyModalCtrl this is like:
var MyModalCtrl = function($scope, $modalInstance, $http, getCostNow) {
function updateOrder()
{
//Trying to invoke getCost function reference here
//But this does not work.
var theCurrentCostIs = getCostNow();
}
}