Using $scope in popup (AngularJS + Ionic)

I followed documentation to set a Ionic popup in my project. This works well except one thing.

When I call the function, I'm not in controller (I'm in services.js), so when I define scope: $scope, I have an obvious $scope is unknown error.

How do you solve this? Thanks a lot !

Find bellow the full code if you need it.

controllers.js

$scope.confirm_redeem_reward = function(asked_reward) {
      RewardModel.displayConfirmRedeemReward(asked_reward)
    };

services.js

...

  RewardModel.displayConfirmRedeemReward = function(asked_reward) {
     var confirmPopup = $ionicPopup.confirm({
       title: 'Confirmation',
       templateUrl: 'templates/popups/confirm_redeem_reward.html',
       scope: $scope,
       buttons: [{
          text: 'Cncel',
          type: 'button-default'
        }, {
          text: 'OK',
          type: 'button-positive',
          onTap: function(e) {
            RewardModel.useReward(asked_reward.id);
            RewardModel.used_reward_or_deal_name = asked_reward.name;
          }
        }]

     });
     confirmPopup.then(function(res) {
       // Nothing
     });
    };

confirm_redeem_reward.html

Do you want to redeem the reward :
{{asked_reward.name}} ?

I think you are using popup in a wrong place. You must separate functionalities and showing a popup is a function that must be in controller instead.

If you do that way, it will work perfectly ;)

I ran into the same dilemma, whether to use a controller or a service. It feels to me that a service is a slightly better solution, since the controller for the popup is already wrapped within ionicPopup function. (I.e. i'm not writing the controller, i just delegate to ionicPopup) So I fixed it for now by injecting rootScope into the service and create the scope myself:

    return {
        showPopup: function () {
            var $scope = $rootScope.$new();
            $scope.data = {};

Still it feels awkward to have UI stuff within a service, so i'm open for alternatives.

Stephan