2016-04-21 29 views
0

我有一個按鈕。如何使用離子彈出?

 <button type="button" class="button button-calm list-inset" 
     ng-click="disable()"> 
      Delete 
     </button> 

當我點擊這個按鈕,我需要顯示一個彈出2個按鈕。取消並且 禁用。 當我點擊禁用彈出應該隱藏和第一個按鈕應該被禁用。 如何做到這一點? 我只需要禁用帶有確認消息的第一個按鈕,該消息由離子彈出窗口提供。

回答

0

你可以在你的HTML做到這一點:

<button class="button button-dark button-block" ng-click="disable()" ng-disabled="ko == true"> 
     Delete 
     </button> 

,並在控制器中設置了這樣的變量:$scope.ko = false; 並在控制器禁用按鈕的功能應該是這樣的:

var popup = $ionicPopup.show({ 
       title: 'disable', 
       scope: $scope, 
       buttons: [ 
       { 
        text: 'Cancel', 
        type: 'button-default', 
        onTap: function (e) { 
        return null; 
        } 
       }, 
       { 
        text: 'OK', 
        type: 'button-dark', 

    onTap: function (e) { 
       return true; 
       } 
      } 
      ] 
     }); 

     popup.then(function (popRes) { 
      if(popRes){ 
       $scope.ko = true; 
       console.log("disable"); 
      } 
     }) 

希望它能幫助你:)。不要忘了加$ ionicPopover在控制器

0
<button type="button" class="button button-calm list-inset" 
     ng-click="disable()"> 
      Delete 
     </button> 

你必須把這個代碼的控制器上,

$scope.disable= function() { 
     var confirmPopup = $ionicPopup.confirm({ 
      title: 'Delete', 
      template: 'Are you sure you want to delete this?' 
     }); 

     confirmPopup.then(function (res) { 
      if (res) { 
       console.log('Deleted !'); 
      } else { 
       console.log('Deletion canceled !'); 
      } 
     }); 
    }; 

而且還注入($範圍,$ ionicPopup)在您的控制器。