Ionic 常用组件解析
Ionic 常用组件解析
$ionicModal(弹出窗口):
//创建一个窗口
//此处注意目录的起始位置为app
$ionicModal.fromTemplateUrl('app/security/model/regist-model.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
//缓存创建的窗口
$scope.registModal = modal;
});
$scope.showRegist = function(){
$scope.registModal.show();
};
$scope.hideDialog = function() {
//隐藏
$scope.registModal.hide();
//移除
//$scope.registModal.remove();
};
$ionicLoading (loading ,可以作为信息提示)
//是否不添加全屏遮罩效果 //自动消失时间
$ionicLoading.show({template:'提示信息', noBackdrop: true, duration: 1500});
$ionicPopup (弹出一个小窗口 输入框,确认框,提示框)
//1.创建一个自定义输入框
$scope.showPopup = function() {
$scope.data = {}
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);
};
//2.普通输入框
$scope.showPopup = function() {
$ionicPopup.prompt({
title: 'Password Check',
template: 'Enter your secret password',
inputType: 'password',
inputPlaceholder: 'Your password',
okText:'OK'
}).then(function(res) {
console.log('Your password is', res);
});
}
//3.确认框
$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');
}
});
};
//4.提示框
$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');
});
};
$ionicPopover (弹出一个带箭头的小对话框)
注意调用方法时不要漏掉 $event 参数
<p>
<button ng-click="openPopover($event)">Open Popover</button>
</p>
//方法一 直接自定义
var template = '<ion-popover-view>' +
'<ion-header-bar>' +
'<h1 class="title">My Popover Title</h1>' +
'</ion-header-bar>'+
'<ion-content> Hello! </ion-content>'+
'</ion-popover-view>';
$scope.popover = $ionicPopover.fromTemplate(template, {
scope: $scope
});
//方法二 引用已存在的html
$ionicPopover.fromTemplateUrl('my-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
$scope.closePopover = function() {
$scope.popover.hide();
};
//拥有的相关事件
//Cleanup the popover when we're done with it!
$scope.$on('$destroy', function() {
$scope.popover.remove();
});
// Execute action on hidden popover
$scope.$on('popover.hidden', function() {
// Execute action
});
// Execute action on remove popover
$scope.$on('popover.removed', function() {
// Execute action
});
ionc-list (列表的使用,包括添加按钮,删除等)
ionc-list(基本列表创建)
<ion-list>
<ion-item ng-repeat="item in items">
Hello, {{item}}!
</ion-item>
</ion-list>
ion-delete-button,ion-reorder-button (delete按钮显示在左方,reorder按钮显示在右方)

<!--
show-delete :控制是否显示删除按钮
show-reorder:控制是否显示reorder按钮
-->
<ion-list show-delete="isShowDelete" show-reorder="isShowEdit" class="my-divider-list">
<ion-item ng-repeat="studyItem in data.studyData">
<div class="item item-divider">
<span class="expect-label">学习内容:</span> <span class="expect-desc">{{studyItem.title}}</span>
</div>
<a class="item" >
<span class="expect-label">日期:</span> <span class="expect-desc">{{studyItem.date|date:'yyyy-M-dd'}}</span>
</a>
<a class="item" >
<span class="expect-label">学习明细:</span> <span class="expect-desc">{{studyItem.desc}}</span>
</a>
<!--
添加删除按钮
-->
<ion-delete-button class="ion-minus-circled" ng-click="deleteStudy(studyItem)">
</ion-delete-button>
<!--
添加reorder 按钮
-->
<ion-reorder-button class="ion-edit" ng-click="showEditStudyDialog(studyItem, $fromIndex, $toIndex)">
</ion-reorder-button>
</ion-item>
</ion-list>
ion-option-button

<!-- can-swipe="true" 添加该属性才能开启滑动附加按钮-->
<ion-list can-swipe="true">
<ion-item ng-repeat="costItem in data.costData">
<div><span class="expect-label">支出金额:</span> <span class="expect-desc">{{costItem.money}}</span></div>
<div><span class="expect-label">支出日期:</span> <span class="expect-desc">{{costItem.date|date:'yyyy-M-dd'}}</span></div>
<div><span class="expect-label">支出明细:</span> <span class="expect-desc">{{costItem.desc}}</span></div>
<!--添加滑动按钮-->
<ion-option-button class="button-info"
ng-click="showEditCost(costItem)">
修改
</ion-option-button>
<ion-option-button class="button-assertive"
ng-click="deleteCost(costItem)">
删除
</ion-option-button>
</ion-item>
</ion-list>
//该方法可以关闭已经显示的按钮
$ionicListDelegate.closeOptionButtons()
ion-slide-box (滑动卡组件)
<!--
active-slide:初始index
show-pager:是否显示下方滑动按钮
on-slide-changed:滑动事件
<ion-slide>滑动的内容
-->
<ion-slide-box active-slide="activeSlideIndex" show-pager="true" on-slide-changed = "productSlideChanged($index)">
<ion-slide ng-repeat="item in data.picTPLdata" >
<div class="list card">
<div class="item">
<h2>{{item.desc1}} <span style ="color: gray;">{{item.desc0}}</span></h2>
</div>
<div class="item item-image">
<img src="{{item.url}}">
</div>
</div>
</ion-slide>
</ion-slide-box>
ion-refresher (下拉刷新数据)
<ion-refresher pulling-text="刷新数据中.." on-refresh="doRefresh()">
</ion-refresher>
$scope.doRefresh = function() {
FGOService.getNoteData()
.then(function(result){
$scope.data.noteData = result;
//关闭刷新提示
$scope.$broadcast('scroll.refreshComplete');
})
};
Ionic 常用组件解析的更多相关文章
- Ext 常用组件解析
Ext 常用组件解析 Panel 定义&常用属性 //1.使用initComponent Ext.define('MySecurity.view.resource.ResourcePanel' ...
- lonic常用组件之五------按钮
一.Ionic常用组件之五------按钮 <ion-button color="主题色" size="small/large" expand=& ...
- .NetCore中的日志(1)日志组件解析
.NetCore中的日志(1)日志组件解析 0x00 问题的产生 日志记录功能在开发中很常用,可以记录程序运行的细节,也可以记录用户的行为.在之前开发时我一般都是用自己写的小工具来记录日志,输出目标包 ...
- Android常用组件
UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...
- Android常用组件【转】
UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...
- 最全面 Nginx 入门教程 + 常用配置解析
转自 http://blog.csdn.net/shootyou/article/details/6093562 Nginx介绍和安装 一个简单的配置文件 模块介绍 常用场景配置 进阶内容 参考资料 ...
- 【转】【Nginx】Nginx 入门教程 + 常用配置解析
== Nginx介绍和安装 == Nginx是一个自由.开源.高性能及轻量级的HTTP服务器及反转代理服务器, 其性能与IMAP/POP3代理服务器相当.Nginx以其高性能.稳定.功能丰富.配置简单 ...
- android开发常用组件【持续更新中。。。】
UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...
- React Native组件(三)Text组件解析
相关文章 React Native探索系列 React Native组件系列 前言 此前介绍了最基本的View组件,接下来就是最常用的Text组件,对于Text组件的一些常用属性,这篇文章会给出简单的 ...
随机推荐
- Day3-递归函数、高阶函数、匿名函数
一.递归函数 定义:函数内部可以调用其它函数,如果调用自身,就叫递归. 递归特性: 1.必须有结束条件退出: >>> def calc(n): ... print(n) ... re ...
- 求数组的最小数、最大值,求一组数的平均数,sort函数详解,类数组转数组
求数组的最小值和最大值 //求数组当中最大值和最小值 var arr=[3,2,6,1,45,23,456,23,2,6,3,45,37,89,30]; //第一种方法 根据排序方法来求最大值和最小值 ...
- 机器学习:Python实现聚类算法(一)之K-Means
1.简介 K-means算法是最为经典的基于划分的聚类方法,是十大经典数据挖掘算法之一.K-means算法的基本思想是:以空间中k个点为中心进行聚类,对最靠近他们的对象归类.通过迭代的方法,逐次更新各 ...
- R语言通过loess去除某个变量对数据的影响
当我们想研究不同sample的某个变量A之间的差异时,往往会因为其它一些变量B对该变量的固有影响,而影响不同sample变量A的比较,这个时候需要对sample变量A进行标准化之后才能进行比较.标 ...
- Java-面向对象总结
下面是学习面向对象的知识点和总结: 面向对象思想: 遇到需求,首先去找是否有现成的类来实现此功能,创建对象来调用,以此来组合成新的类实现自己的需求. 在java中是以类为单位,一个类包括成员变量.成员 ...
- netty心跳机制测试
netty中有比较完善的心跳机制,(在基础server版本基础上[netty基础--基本收发])添加少量代码即可实现对心跳的监测和处理. 1 server端channel中加入心跳处理机制 // Id ...
- 写markdown博客如何截图并快速上传到图床——记一个工具插件的实现
1. 背景 写博客有一个自己的图床是不错的选择,如果不借助工具,在markdown博客中添加图片的步骤如下: 截取图片,保存到本地(得来回点对话框,选择保存路径,选择文件类型,输入文件名). 上传到图 ...
- 一天搞定CSS:表格(table)--19
1.表格标签 表格标签的嵌套关系 <table> <!--表格头--> <thead> <!--表格行--> <tr> <!--表格列 ...
- 提升单元测试体验的利器--Mockito使用总结
为神马要使用Mockito? 在编写单元测试的时候,为了尽可能的保证隔离性,我们时常需要对某些不容易构造或者不容易获取或者对外部环境有依赖的对象,用一个虚拟的对象来创建以便于测试.假设你正在开发的的代 ...
- 那些日常琐事(iPhone上的细小提示,大数据分析)
今天早上蹲坑玩手机的时候,无意间看到了iPhone 给我一些提醒,震惊了我.也许你们会说,没什么大惊小怪的,当然做程序的都知道苹果公司早就记载了我们日常生活中很多数据,只是苹果公司目前还没做 ...