Ionic - Didn't return value $scope in $ionicPopup.show inside factory
<p>I created a project with <code>$ionicPopup</code>. I put the <code>$ionicPopup</code> code in a <code>.factory</code>. In my <code>$ionicPopup.show()</code> I ask user to input a value. After users already input the value, then it will alert the value what the user's wrote.</p>

<p>I also checked the following post, but still cannot solve my problem <a href="https://stackoverflow.com/questions/29859887/access-scope-inside-an-angular-js-factory">Access scope inside an angular js factory</a> .</p>

<p>So here is my code:</p>

<p><strong>controller</strong></p>

<pre><code>.controller('PopupCtrl',function($scope, $ionicPopup, $timeout, popupService) {

 // Triggered on a button click, or some other target
 $scope.showPopup = function() {

   var showParameter = {
     title: "Test",
     cssClass: "",
     subTitle: "Insert any value",
     template: '&lt;input type="text" ng-model="value"&gt;',
     templateUrl: "",
     buttons: {
       cancelText: "Reject",
       cancelType: "button-assertive",
       okText: "Accept",
       okType: "button-positive"
     }
   }

   // An elaborate, custom popup
   popupService.show(showParameter, $scope).then(function(res) {
     console.log('Tapped!', res);
     alert("value: " + res);
   });
  };
})
</code></pre>

<p><strong>factory</strong></p>

<pre><code>.factory('popupService', function ($ionicPopup) {
    return{
        show: function(param, scope){
          var show = $ionicPopup.show({
              title: param.title, // String. The title of the popup.
              cssClass: param.cssClass, // String, The custom CSS class name
              subTitle: param.subTitle, // String (optional). The sub-title of the popup.
              template: param.template, // String (optional). The html template to place in the popup body.
              templateUrl: param.templateUrl, // String (optional). The URL of an html template to place in the popup   body.
              scope: scope, // Scope (optional). A scope to link to the popup content.
              buttons: [{ // Array[Object] (optional). Buttons to place in the popup footer.
                text: param.buttons.cancelText,
                type: param.buttons.cancelType,
                onTap: function(e) {
                  return false;
                }
              }, {
                text: param.buttons.okText,
                type: param.buttons.okType,
                onTap: function(e) {
                  // Returning a value will cause the promise to resolve with the given value.
                  return scope.value;
                }
              }]
           });
          return show;
        }
    }
 });
</code></pre>

<p><strong>DEMO:</strong> <a href="http://codepen.io/aishahismail/pen/pgpdGW?editors=101" rel="nofollow noreferrer">http://codepen.io/aishahismail/pen/pgpdGW?editors=101</a></p>

<p>Your help is really need. Thank you.</p>