How to display Ionic popup from popover option?

I have a popover in my Ionic framework app with options: sharing and deleting. I need to display a confirmation popup when the delete option is selected, but I don't know how to do this.

How can I do that? Do I need to create a separate controller for popover? I already made a popup from ActionSheet, but it is somehow different.

This is the controller:

$ionicPopover.fromTemplateUrl('templates/popover.html', { scope: $scope }).then(function(popover) { $scope.popover = popover; }); // Triggered on a button click, or some other target $scope.openPopover = function($event) { $scope.popover.show($event); }; 

And this is the popover pattern:

 <ion-popover-view style="height: 120px"> <ion-content> <div class="list"> <a class="item"> Compartir </a> <a class="item"> Eliminar </a> </div> </ion-content> </ion-popover-view> 
+7
javascript angularjs ionic-framework ionic
source share
1 answer

You can put ng-click in your delete (or Eliminar in your template, I think?)

 <ion-popover-view style="height: 120px"> <ion-content> <div class="list"> <a class="item"> Compartir </a> <a class="item" ng-click="showConfirm()"> Eliminar </a> </div> </ion-content> </ion-popover-view> 

 $ionicPopover.fromTemplateUrl('templates/popover.html', { scope: $scope }).then(function(popover) { $scope.popover = popover; }); // Triggered on a button click, or some other target $scope.openPopover = function($event) { $scope.popover.show($event); }; $scope.showConfirm = function() { var confirmPopup = $ionicPopup.confirm({ title: 'Are you sure?', template: 'Are you sure you want to delete?' }); confirmPopup.then(function(res) { if(res) { console.log('You are sure'); } else { console.log('You are not sure'); } }); }; 
+11
source share

All Articles