我的Ionic框架应用程序中有一个popover,带有选项:共享和删除。我需要在选择删除选项时显示确认弹出窗口,但我不知道如何。
如何做到这一点?我是否需要为弹出窗口创建单独的控制器?我已经从ActionSheet做了一个弹出窗口,但这有点不同。
这是控制器:
select colname from tablename where (select precision from sys.columns
where name='<colname>') > 4;
这是popover模板:
$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);
};
答案 0 :(得分:12)
您可以在删除时放置ng-click
(我认为您的模板中有Eliminar吗?)
<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');
}
});
};