ionic 对话框
作者:SunnyJourney
时间:2026-08-11
来源:正软商城
浏览:1
$ionicPopup ionic 提供的对话框服务,可以让程序按需创建并显示弹窗。 $ionicPopup 一共提供了 3 个常用方法,分别是 alert()、prompt() 和 confirm()。 实例 HTML 代码 弹窗显示 确认对话框 警告框 Ja vaScript 代码 angula
本文目录
$ionicPopup
ionic 提供的对话框服务,可以让程序按需创建并显示弹窗。

$ionicPopup 一共提供了 3 个常用方法,分别是 alert()、prompt() 和 confirm()。
实例
HTML 代码
Ja vaScript 代码
angular.module('mySuperApp', ['ionic'])
.controller('PopupCtrl',function($scope, $ionicPopup, $timeout) {
// Triggered on a button click, or some other target
$scope.showPopup = function() {
$scope.data = {}
// 自定义弹窗
var myPopup = $ionicPopup.show({
template: '',
title: 'Enter Wi-Fi Password',
subTitle: 'Please use normal things',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: 'Sa ve',
type: 'button-positive',
onTap: function(e) {
if (!$scope.data.wifi) {
// 不允许用户关闭,除非输入 wifi 密码
e.preventDefault();
} else {
return $scope.data.wifi;
}
}
},
]
});
myPopup.then(function(res) {
console.log('Tapped!', res);
});
$timeout(function() {
myPopup.close(); // 3秒后关闭弹窗
}, 3000);
};
// confirm 对话框
$scope.showConfirm = function() {
var confirmPopup = $ionicPopup.confirm({
title: 'Consume Ice Cream',
template: 'Are you sure you want to eat this ice cream?'
});
confirmPopup.then(function(res) {
if(res) {
console.log('You are sure');
} else {
console.log('You are not sure');
}
});
};
// alert(警告) 对话框
$scope.showAlert = function() {
var alertPopup = $ionicPopup.alert({
title: 'Don't eat that!',
template: 'It might taste good'
});
alertPopup.then(function(res) {
console.log('Thank you for not eating my delicious ice cream cone');
});
};
});
作者最新文章
俄罗斯Yandex官网入口及外贸查询工具
2026-11-16 17:53
Yandex官网入口及网页搜索使用方法
2026-11-10 18:27
免注册Word转PDF在哪里?Word转PDF手机电脑都能用
2026-11-08 15:29
xshell如何使用密钥连接服务器
2026-11-05 21:38
动漫共和国资源入口及正版地址分享
2026-11-04 12:05
热门文章
更多
精品专题
更多
Mac软件
更多
火山引擎 网页版
Windows/ macOS/ Linux
火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。
















