Popover error

Hi everyone!

I’m using a simple popover method here’s the code:

$scope.popover = $ionicPopover.fromTemplateUrl('templates/popover/config-header.html', {
    scope: $scope
}).then(function (popover) {
    $scope.popover = popover;
});


$scope.openPopover = function ($event) {
    $scope.popover.show($event);
};
$scope.closePopover = function () {
    $scope.popover.hide();
};
/*    $scope.logout = function(){
 $state.go('app.login');
 };*/
//Cleanup the popover when we're done with it!
$scope.$on('$destroy', function () {
    $scope.popover.remove();
});
// Execute action on hide popover
$scope.$on('popover.hidden', function () {
    // Execute action
});
// Execute action on remove popover
$scope.$on('popover.removed', function () {
    // Execute action
});

but I got a weird error: Cannot call popover.show() after remove(). Please create a new popover instance.

I say weird because I didn’t find something similar so far (here or on google)

Anyone had this problem?

Thanks!

1 Like

Have same problem…please help!

Have find a solution!
Read this http://ionicframework.com/docs/api/controller/ionicPopover/

Don’t forget to put this script after popover shown

$scope.$on(’$destroy’, function() {
$scope.popover.remove();
});

But I do have this piece of code above right? I’m not having this problem anymore but I didn’t know what was happening or how to effectively reproduce the error.

But thanks a lot for your help, glad it worked out for you! :smile: