Popup and Close

I want to put a button on top of the popup, is that possible?

What I am doing is putting an image on top with CSS inside the popup code.

Thing is, var popup = {…}

If I add onClick=“popup.close()”, I get an error. However popup.close() works just fine for the Cancel button, but popup.close() is not inside the Javascript code itself. I already tried this.close(); and that does not work either.

1 Like

Like this:

Inside the Popup, put the same controller you are using. So $scope.myPopup is inside DriversCtrl. And the method closethis() is also inside that controller. When the user clicks on the X, the popup closes.

$scope.myPopup = $ionicPopup.show({
     template: '<div><p>content</p></div><div style="position: absolute; top: 0px; left: 0px" ng-controller="DriversCtrl" ng-Click="closethis();">X</div>',
     title: 'Vehicle Information',
     subTitle: $filter('formatDistance')(distance) + ' near you',
     scope: $scope,
     buttons: [
       { text: 'Cancel' },
       {
         text: '<b>Agree</b>',
         type: 'button-positive',
         onTap: function(e) { } else {  }
       },
     ]
   });
$scope.closethis = function()
  {
       $scope.myPopup.close();
  };
1 Like

Hi @rpcarnell I hope this will be useful for you, please see this Codepen Link.

Sorry I don’t know, Why I can’t embed the codepen in this post?

1 Like

I think you only need to paste the codepen link

Edit: Nope :frowning: