2015-09-10 62 views
0

我创建了一个离子应用程序,其中弹出窗口打开,要求用户评价这个应用程序,如果他以前没有评价这个应用程序。离子弹出显示正确,但我的问题是,用户必须点击/点击取消按钮两次关闭弹出式窗口,有时点击/点击不起作用。离子弹出关闭不起作用

我的代码如下:

(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); 
    }); 

})(); 

我该如何解决这个问题?

+0

你在哪里测试您的应用程序?你使用的是哪个版本的框架? – LeftyX

+0

我在android模拟器上测试我的应用程序,离子版本是1.6.4 – sabbir

+0

这个$ scope变量来自哪里?它是打算成为一个干净的$范围(因此封闭函数()?) –

回答

2

你可以试试这个

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(); 
    }) 
+0

谢谢你的回答,但当我试图显示弹出式开关的情况下,它不工作确实知道它的任何解决方案 – Pritish

+0

case'false':$ ionicPopup.show({title:'无效密码!',模板:'请输入有效',范围:$ scope,buttons:[{text:'Ok',type:'button-positive',onTap:function(e){}}]});对于开关盒它不工作 – Pritish

1

请看看我为你所做的codepen:

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(); 

此代码的工作,我只是增加了一个函数来调用弹出点击右上角的按钮时。

我希望它能解决您的问题!

+0

点击事件的作品,但我需要自动加载弹出 – sabbir

+0

然后,在函数初始化后,调用$ scope.openPopup(); 我把它添加到codepen –

+0

谢谢你的回答,但是当我试图显示弹出式开关的情况下,它不工作知道它的任何解决方案 – Pritish