0

I have created an ionic app where a popup window is opened to ask user to rate this app if he did not rate this app previously. Ionic popup appear correctly, but my problem is, user have to click/tap on cancel button twice to close popup and sometimes click/tap is not working.

My code is given below:

 (function() {

      $scope.data = {}

      var myPopup = $ionicPopup.show({
        template: '<input type="range" ng-model="data.user_ratting">',
        title: 'Do you want to rate this app?',
        scope: $scope,
        buttons: [
          { text: 'Cancel' },
          {
            text: '<b>Save</b>',
            type: 'button-positive',
            onTap: function(e) {

             }
          }
       ]
  });

    myPopup.then(function(res) {
      console.log('Tapped!', res);
    });

 })();

How can I solve this problem??

3
  • Where are you testing your app? Which version of the framework are you using?
    – LeftyX
    Commented Sep 10, 2015 at 8:43
  • I test my app on android emulator and ionic version is 1.6.4
    – sabbir
    Commented Sep 10, 2015 at 8:45
  • Where does this $scope variable comes from? Is it intended to be a clean $scope (Hence the enclosing function() ?) Commented Sep 10, 2015 at 8:47

2 Answers 2

2

can you try this one

var popup = $ionicPopup.show({
    title: 'Enter Wi-Fi Password',
    subTitle: 'Please use normal things',
    scope: $scope,
    buttons: [
              { text: 'ready',  onTap: function(e) {
                  console.log(e);
                  return true; 
                } 
           }
             ]
  }).then(function(result){
    console.log('Tapped', result);
  }, function(error){
    console.log('error', error);
  }, function(popup){
    popup.close();
  })
2
  • thanks for answer but when I try to show the popup in switch case its not working do know any solution for it
    – Pritish
    Commented Jan 10, 2017 at 13:21
  • case 'false': $ionicPopup.show({ title: 'Invalid Passcode!', template: 'Please enter valid Passcode.', scope: $scope, buttons: [ { text: '<b>Ok</b>', type: 'button-positive', onTap: function(e) { } } ] }); for switch case its not working
    – Pritish
    Commented Jan 10, 2017 at 13:22
1

Please have a look at the codepen I Did for you :

http://codepen.io/privetr/pen/QjjyMB

$scope.openPopup = function() {
  var myPopup = $ionicPopup.show({
    template: '<input type="range" ng-model="data.user_ratting">',
    title: 'Do you want to rate this app?',
    scope: $scope,
    buttons: [
      { text: 'Cancel' },
      {
        text: '<b>Save</b>',
        type: 'button-positive',
        onTap: function(e) {

         }
      }
   ]
});

myPopup.then(function(res) {
  console.log('Tapped!', res);
});
}

// To automatically open the popup
$scope.openPopup();

this code works, I just added a function to call the Popup when the top right button is clicked.

I hope it will solves your problem !

4
  • click event works, but I need to load popup automatically
    – sabbir
    Commented Sep 10, 2015 at 8:55
  • Then, after the initialization of the function, call $scope.openPopup(); I added it to the codepen
    – Rémi P
    Commented Sep 10, 2015 at 8:59
  • thanks for answer but when I try to show the popup in switch case its not working do know any solution for it
    – Pritish
    Commented Jan 10, 2017 at 13:06
  • case 'false': $ionicPopup.show({ title: 'Invalid Passcode!', template: 'Please enter valid Passcode.', scope: $scope, buttons: [ { text: '<b>Ok</b>', type: 'button-positive', onTap: function(e) { } } ] });
    – Pritish
    Commented Jan 10, 2017 at 13:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.