When launching a modal from my web page, I am updating an array passed from the parent. However, when closing the modal and sending back the updated results, the parent scope object is also being updated. If the user decides not to update and cancels the modal, I do not want those changes reflected in my parent controller.
Parent Controller Code:
const modalInstance = $modal.open({ templateUrl: '/app/modal.html', controller: 'modalController', controllerAs: 'modal', resolve: {
mappedData: () => parentCntrl.groupData } });modalInstance.result.then(result => { if (result) { parentCntrl.groupData = result; } });
Child Controller Code:
modal.ok = () => { $modalInstance.close(modal.mappedData); };
modal.close = () => { $modalInstance.close(); };