I have an item which can be clicked and uses this function to display a popup:
$scope.view_item = function()
{
// builds template here
// builds buttons, etc
$scope.ionicPopup = $ionicPopup.alert({
title: "",
template: template,
cssClass: "custom-popup-1",
scope: $scope,
buttons: [
{
text : "Confirm",
type : "",
onTap : ontapConfirm
},
{
text : "Cancel",
type : "",
onTap : ontapCancel
}
]
});
}
In this popup, I have a “Reason” field which allows users to select from a number of reasons using a modal. I am using an ng-repeat
inside a modal instead of a <select>
field for this. When the field is clicked, it calls this function:
$scope.open_reason_options = function()
{
$scope.ionicPopup.close();
$scope.modal = $ionicModal.fromTemplate(
'<ion-modal-view cache-view="false">' +
'<ion-header>' +
'<ion-nav-bar align-title="center">' +
'<ion-nav-buttons side="left"><button class="button button-icon ion-close-round" ng-click="closeModal();"></button></ion-nav-buttons>' +
'<ion-nav-title>Select Reason</ion-nav-title>' +
'</ion-nav-bar>' +
'</ion-header>' +
'<div class="outer-page-panel">' +
'<ion-content class="has-header">' +
'<ion-list>' +
'<span ng-repeat="reason in reasons">' +
'<ion-radio class="hide-icon" ng-click="onReasonSelect(reason);" ng-model="line.reason" ng-value="reason.reason_code" ng-if="reason.reason_code != \'\'">' +
'<span class="radio-list-items">' +
'<h2 ng-bind="reason.description"></h2>' +
'</span>' +
'</ion-radio>' +
'</span>' +
'</ion-list>' +
'</ion-content>' +
'</div>' +
'</ion-modal-view>',
{
scope : $scope,
animation: 'slide-in-up'
});
$scope.modal.show();
}
So the idea is that it closes the popup so it focuses on the modal so the user can select a reason. When I click the close button I have added on the modal navigation bar it calls this function:
$scope.closeModal = function()
{
$scope.modal.hide();
$scope.modal.remove();
$scope.view_item();
}
Since the user did not select a reason, I want it to return to the popup with the rest of the data and make no changes. I do that by hiding and removing the current modal and then calls the view_item()
function again to display the popup.
Once the popup re-opens, I can’t do anything on it. I can’t click the buttons at all. Any ideas on how to solve this?