scope is undefined after callback from $uibModal
I have a directive (Angularjs) that has a controller, from there I am calling an uibModal where I want to modify some details of an object where I clicked. With the modal I am sending two parameters and a callback, everything seems to be ok but when angular go back to the callback function the scope of the controller (not the modal controller) is undefined, actually everything is undefined, how can I comunicate these two controllers, so when the user update something in the modal I can update it in the other controller.
modal.controller
(function () {
"use strict";
angular
.module("app.users")
.controller("editVitalCtrl", editVitalCtrl);
editVitalCtrl.$inject = ["items"];
function editVitalCtrl(items) {
var vm = this;
vm.modalTitle = "Edit " + items.vital.title;
vm.vital = items.vital;
vm.clickCancelModal = function () {
vm.$close();
}
vm.clickSaveModal = function () {
$scope.$result(items.saveCallback($scope.vital));
}
}
})();
directiveThatOpenTheModal.directive.js
(function () {
"use strict";
angular
.module("app.users")
.directive("directiveThatOpenTheModal", [
function () {
return {
restrict: "E",
scope: {
columnConfig: "=columnConfig",
partnerId: "=partnerId"
},
link: {
pre: function (scope) {
}
},
controller: ["$http", "$scope", "$uibModal",
function ($http, $scope, $uibModal) {
$scope.vitalList = [];
if ($scope.partnerId) {
var params = {
bankId: Number.isInteger($scope.partnerId) ? $scope.partnerId : -1
};
getColumnConfiguration(params, $http).success(function (data) {
$scope.vitalList = data.columns;
});
}
$scope.removeVital = function (vital) {
removeVital(vital);
}
function callback(vital) {
// Code here in callback, after code get in here everythings is undefined
}
$scope.editVital = function (vital) {
$scope.modal = $uibModal.open({
animation: true,
windowClass: 'modal-add-cont modal-alerts',
templateUrl: '/controller/view',
controller: 'modalCtrl',
resolve: {
items: function () {
return {
vital: vital,
saveCallback: callback,
partnerId: $scope.partnerId,
scope: $scope
}
}
},
size: 'lg'
});
}
function removeVital(vital) {
var index = $scope.vitalList.indexOf(vital);
$scope.vitalList.splice(index, 1);
}
}],
templateUrl: '/route/Configuration'
};
}]);
function getColumnConfiguration(params, $http) {
var url = "/someroute/somemethod";
return $http.get(url, { params: params });
}
})();