$ionicPopup
转自:http://www.ionicframework.com/docs/api/service/%24ionicPopup/
Usage
A few basic examples, see below for details about all of the options available.
angular.module('mySuperApp', ['ionic']) .controller('PopupCtrl',function($scope, $ionicPopup, $timeout) { // Triggered on a button click, or some other target $scope.showPopup = function() { $scope.data = {} // An elaborate, custom popup var myPopup = $ionicPopup.show({ template: '<input type="password" ng-model="data.wifi">', title: 'Enter Wi-Fi Password', subTitle: 'Please use normal things', scope: $scope, buttons: [ { text: 'Cancel' }, { text: '<b>Save</b>', type: 'button-positive', onTap: function(e) { if (!$scope.data.wifi) { //don't allow the user to close unless he enters wifi password e.preventDefault(); } else { return $scope.data.wifi; } } } ] }); myPopup.then(function(res) { console.log('Tapped!', res); }); $timeout(function() { myPopup.close(); //close the popup after 3 seconds for some reason }, 3000); }; // A confirm dialog $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'); } }); }; // An alert dialog $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'); }); }; });
Methods
show(options)
Show a complex popup. This is the master show function for all popups.
A complex popup has a buttons
array, with each button having a text
and type
field, in addition to an onTap
function. The onTap
function, called when the corresponding button on the popup is tapped, will by default close the popup and resolve the popup promise with its return value. If you wish to prevent the default and keep the popup open on button tap, call event.preventDefault()
on the passed in tap event. Details below.
Param | Type | Details |
---|---|---|
options |
object
|
The options for the new popup, of the form:
|
- Returns:
object
A promise which is resolved when the popup is closed. Has an additionalclose
function, which can be used to programmatically close the popup.
alert(options)
Show a simple alert popup with a message and one button that the user can tap to close the popup.
Param | Type | Details |
---|---|---|
options |
object
|
The options for showing the alert, of the form:
|
- Returns:
object
A promise which is resolved when the popup is closed. Has one additional functionclose
, which can be called with any value to programmatically close the popup with the given value.
confirm(options)
Show a simple confirm popup with a Cancel and OK button.
Resolves the promise with true if the user presses the OK button, and false if the user presses the Cancel button.
Param | Type | Details |
---|---|---|
options |
object
|
The options for showing the confirm popup, of the form:
|
- Returns:
object
A promise which is resolved when the popup is closed. Has one additional functionclose
, which can be called with any value to programmatically close the popup with the given value.
prompt(options)
Show a simple prompt popup, which has an input, OK button, and Cancel button. Resolves the promise with the value of the input if the user presses OK, and with undefined if the user presses Cancel.
$ionicPopup.prompt({title: 'Password Check', template: 'Enter your secret password', inputType: 'password', inputPlaceholder: 'Your password' }).then(function(res) { console.log('Your password is', res); });
Param | Type | Details |
---|---|---|
options |
object
|
The options for showing the prompt popup, of the form:
|
- Returns:
object
A promise which is resolved when the popup is closed. Has one additional functionclose
, which can be called with any value to programmatically close the popup with the given value.
转载于:https://www.cnblogs.com/1992825-Amelia/p/4847076.html
最新文章
- 转 如何利用客户端缓存对网站进行优化?
- U盘中病毒,文件消失或不显示
- 【C++】42.使用YAML文件进行参数配置、读取与生成YAML文件
- Java设计模式GOF之6大设计原则
- 如何快速理解递归——蓝桥杯 试题 基础练习 FJ的字符串(递归与非递归解法)——10行代码AC
- 无限乱斗机器人ap出装_另类出装畅玩无限乱斗!AP小丑成致胜黑科技
- 深度学习03——CNN
- MySQL 异常:这一篇就够了,MySQL 抛出异常的几种常见解决方式小结
- AC_Dream 1211 Reactor Cooling
- Python列表常用函数使用详解(内附详细案例)
- linux gfs文件系统,Linux环境下使用GFS文件系统
- portlet示例_Java Portlet示例教程
- 西门子S7-200 SMART编程软件下载
- Python数据处理Tips日期、时间数据处理方法汇总
- 程序设计-股票最大收益问题(Java)
- 集成基站混频器本振噪声的规格与测量
- 记一次Python爬取某网站公众号二维码的过程
- __stack_chk_fail之栈帧溢出检测技术
- String转int问题分析
- GCP---Google cloud Platform
热门文章
- ansys电力变压器模型_变压器模型……一切是如何开始的?
- 假如购买的期房不小心烂尾了,那银行贷款是否可以不还了?
- 乱用信用卡?黑名单见
- 银行员工会购买自己银行的理财产品吗?
- 身体好不是锻炼出来的
- mysql 互为主备 宕机 数据丢失_Devops部署-mysql主备多从搭建
- 本机用域名不能访问_域名注册申请网站域名注意事项
- pgsql vs mysql查询_对比平台--SQL Server Vs PostgreSQL
- python课程的中期报告_电子课程设计中期报告
- java中怎么使用json数据_JAVA中使用JSON进行数据传递