Open popup from multiple places

Is there a way to declare a popup as a $scope object i.e. $scope.myPopup = $ionicPopup({ MyConfigStuffHere}) and then be able to open the popup by calling it elsewhere in the code i.e. $scope.myPopup.show()?

Whenever i’ve attempted this i get “$scope.myPopup.show() is not a method”

Or do you HAVE to declare the popup AND call the “show” method all at once? I would think this object could/should be reusable in such a manner.

thanks for any help.

$ionicPopup is not a method. That is correct.
and why would you want to do that ?

i’ve not used ionicV1 for months but i think the following will work

Dont throw tomato if it won’t :slight_smile:

$scope.myPopup = $ionicPopup;

$scope.MyConfigStuff = {
    template: '<input type="password" ng-model="data.wifi">',
    title: 'Enter Wi-Fi Password',
    subTitle: 'Please use normal things',
    scope: $scope,
    buttons: [
      { text: 'Cancel' },
      {
        text: '<b>Save</b>',
        type: 'button-positive',
        onTap: function(e) {
          if (!$scope.data.wifi) {
            //don't allow the user to close unless he enters wifi password
            e.preventDefault();
          } else {
            return $scope.data.wifi;
          }
        }
      }
    ]
  }


    //Show popup

    $scope.myPopup.show($scope.MyConfigStuff);