如何从弹出选项显示 Ionic 弹出窗口?
How to display an Ionic popup from a popover option?
我的 Ionic 框架应用程序中有一个带有选项的弹出窗口:共享和删除。我需要在选择删除选项时显示确认弹出窗口,但我不知道如何。
如何做到这一点?我需要为弹出窗口创建一个单独的控制器吗?我已经做了一个来自 ActionSheet 的弹出窗口,但这有点不同。
这是控制器:
$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);
};
这是弹出窗口模板:
<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>
你可以在你的删除上放置一个 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');
}
});
};
我的 Ionic 框架应用程序中有一个带有选项的弹出窗口:共享和删除。我需要在选择删除选项时显示确认弹出窗口,但我不知道如何。
如何做到这一点?我需要为弹出窗口创建一个单独的控制器吗?我已经做了一个来自 ActionSheet 的弹出窗口,但这有点不同。
这是控制器:
$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);
};
这是弹出窗口模板:
<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>
你可以在你的删除上放置一个 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');
}
});
};