Hello everybody,
I come to you to fix a problem with ionic modal.
I have two views one for the home page and another for a scanner and showing a modal.
-
I start in my home page, when i go to the ScannerPage everything work good i can scan and the modal show me the result of the scan .
-
I back to my home page
-
And when i return to my ScannerPage to make a another scan the modal.show() make me this error :
Cannot call modal.show() after remove(). Please create a new modal instance
Modal call in my ScannerPage Controller :
$ionicModal.fromTemplateUrl('my-modal.html', {
scope: $scope,
animation: 'fade-in',
backdropClickToClose: false
}).then(function(modalMyResult) {
$scope.modalResult = modalMyResult;
});
$scope.$on('$destroy', function() {
console.log("destroy");
$scope.modalResult.remove();
$scope.modalResult == null;
});
$scope.closeResultModal = function() {
$scope.modalResult.hide();
};
$scope.openResultModal = function() {
$scope.modalResult.show();
};
my-modal in my ScannerPage.html :
<script id ="my-modal.html" type="text/ng-template">
<ion-modal-view style="width: 70%; height: 50%; top: 35%; left: 15%; right: 15%; bottom: 15%; min-height: 0;">
<ion-header-bar class="bar bar-header bar-header-modal-result">
<h1 class="title" style="color: white;">RÉSULTAT</h1>
<div class="button button-clear" ng-click="closeResultModal()"><span class="icon ion-close"></span></div>
</ion-header-bar>
<ion-content class="has-header easyscan-list" padding="true">
<div class="list-group">
<a class="list-group-item list-group-item-{{$index + 1}}" ng-repeat="item in items" ng-click="selectItem(item)">
<span class="item-name">{{item.name}}</span>
</a>
</div>
</ion-content>
</ion-modal-view>
</script>
function to call my modal in my controller :
function sucessScan(value)
{
loadFromDatabase(value);
$scope.openResultModal();
}
I hope you can help me and if you have question ask me.
Thanks all,
Jeoffrey.