2015-09-10 61 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