0
我試圖打開彈出式窗口,當用戶點擊操作表上的「自定義」按鈕時,我無法弄清楚如何在兩者之間進行交互。我最好的猜測是在下面,當我在視圖中調用ng-click =「showPrompt()」時,彈出窗口被觸發,但是當我嘗試從操作表的buttonClicked事件中執行它時,它是一個禁止行爲。如何點擊ionicActionSheet選項打開ionicPopup?
.controller('TablesCtrl', function($scope, $ionicPopup, $ionicActionSheet) {
$scope.tables = [];
/* Choose Number of Guests */
$scope.showActionsheet = function($ionicPopup) {
$ionicActionSheet.show({
titleText: 'How many guests?',
buttons: [
{ text: '1' },
{ text: '2' },
{ text: '3' },
{ text: '4' },
{ text: '5' },
{ text: '6' },
{ text: 'Custom' }
],
cancelText: 'Cancel',
cancel: function() {
console.log('CANCELLED');
},
buttonClicked: function(index, $ionicPopup) {
console.log('BUTTON CLICKED', index);
if(index==6){showPrompt();}
return true;
}
});
};
/* CUSTOM Number of Guests */
$scope.showPrompt = function() {
var myPopup = $ionicPopup.show({
template: '<input type="password" ng-model="data.wifi">',
title: 'Enter Wi-Fi Password',
subTitle: 'Please use normal things',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: '<b>Save</b>',
type: 'button-positive',
onTap: function(e) {
if (!$scope.data.wifi) {
//don't allow the user to close unless he enters wifi password
e.preventDefault();
} else {
return $scope.data.wifi;
}
}
},
]
});
};
})
大聲笑,我知道這將是一些簡單。對不起,對於Angular來說還是新手,即使是MVC也是如此。非常感謝! – jdgower 2014-08-29 13:32:06
會做。 6分鐘,直到我可以標記。 – jdgower 2014-08-29 13:35:39