2015-04-27 27 views
7

Tôi có một cửa sổ bật lên trong ứng dụng khung Ionic của tôi với các tùy chọn: chia sẻ và xóa. Tôi cần hiển thị cửa sổ bật lên xác nhận khi tùy chọn xóa được chọn, nhưng tôi không biết cách thực hiện.Làm cách nào để hiển thị cửa sổ bật lên Ionic từ tùy chọn bật lên?

Làm cách nào để thực hiện điều này? Tôi có cần phải tạo một bộ điều khiển riêng cho cửa sổ bật lên không? Tôi đã làm một popup từ một ActionSheet nhưng điều này là bằng cách nào đó khác nhau.

Đây là bộ điều khiển:

$ionicPopover.fromTemplateUrl('templates/popover.html', { 
    scope: $scope 
}).then(function(popover) { 
    $scope.popover = popover; 
}); 

// Triggered on a button click, or some other target 
$scope.openPopover = function($event) { 

    $scope.popover.show($event); 
}; 

Và đây là popover mẫu: (? Hoặc Eliminar trong mẫu của bạn, tôi nghĩ)

<ion-popover-view style="height: 120px"> 
    <ion-content> 
    <div class="list"> 
     <a class="item"> 
     Compartir 
     </a> 
     <a class="item"> 
     Eliminar 
     </a> 
    </div> 
    </ion-content> 
</ion-popover-view> 

Trả lời

11

Bạn có thể đặt một ng-click về xóa của bạn

<ion-popover-view style="height: 120px"> 
    <ion-content> 
    <div class="list"> 
     <a class="item"> 
     Compartir 
     </a> 
     <a class="item" ng-click="showConfirm()"> 
     Eliminar 
     </a> 
    </div> 
    </ion-content> 
</ion-popover-view> 

$ionicPopover.fromTemplateUrl('templates/popover.html', { 
    scope: $scope 
}).then(function(popover) { 
    $scope.popover = popover; 
}); 

// Triggered on a button click, or some other target 
$scope.openPopover = function($event) { 

    $scope.popover.show($event); 
}; 

$scope.showConfirm = function() { 
    var confirmPopup = $ionicPopup.confirm({ 
    title: 'Are you sure?', 
    template: 'Are you sure you want to delete?' 
    }); 
    confirmPopup.then(function(res) { 
    if(res) { 
     console.log('You are sure'); 
    } else { 
     console.log('You are not sure'); 
    } 
    }); 
}; 
Các vấn đề liên quan