I have a modal that's opened with a new controller of its own, and I want to call a function from the modal controller, but the function is defined in the parent controller.
I defined this function to be invoked from $rootScope, is this the best way to call a function from a parent in the modal or will it make sense in the future?
Example:
FormModule.controller("formCtrl", function ($scope, $http, $uibModal, $log, $rootScope) {
$rootScope.ShowReport = function ShowReport() {
//function Edit
$scope.edit = function () {
var ObjResolve = function () {
return obj;
}
var modalInstance= $uibModal.open({
animation: true,
templateUrl: 'Modal.html',
controller: 'ModalInstanceCtrl',
resolve: {
ObjResolve
}
}).result.catch(function (res) {
if (!(res === 'cancel' || res === 'escape key press')) {
//throw res;
}
});
};
});
FormModule.controller("ModalInstanceCtrl", function ($scope, $uibModal, $uibModalInstance, $http, ObjResolve, $rootScope ) {
//save Event
$scope.save = function () {
$rootScope.ShowReport();
}
});