今天是学习ionic的第二天,其实感觉还挺有意思的,好记性不如烂笔头,把今天学习到的东西都记录下。。。。方便以后自己翻阅
ionic中的www文件夹是我们在实际开发当中必须要用到的文件夹,html、css、js、img的存放都在其中。。。。
1、www/js 文件夹
app.js一般用于创建一个应用程序:angular.module("app",[ionic]);
routes.js配置路由 关键字有:config、state、url、templates、views等等
controllers.js 控制器文件,与routes.js搭配使用,有些也可直接写在routes.js中
2、www/templates 存放不同页面的html文件夹
tabs.html 导航栏 链接不同页面
tab-home.html home页面
tab-setting.html 设置页面
等等
ion-nav-view标签在tabs.html和index.html中都有,用于显示导航栏信息并且可以链接到不同的页面
3、一些标签的使用:
1).设置item图片:item-avatar
2).ion-option-button:把item向左华东的时候 出现的按钮 可自定义(删除、分享)
3).删除的时候splice重新排序:$scope.list.splice($scope.list.indexOf(item),1);
4).设置删除动画:item-remove-animate
5).移动:需要设置成可以移动的状态show-reorder="true"
6).ion-reorder-button设置移动的按钮(右侧)
7).on-reorder 检测移动触发移动的方法on-reorder="move(item,$fromIndex, $toIndex)"
8).移动时候内部逻辑:$scope.move = function (item,fromIndex,toIndex) {
$scope.list.splice(fromIndex,1);
$scope.list.splice(toIndex,0,item);
}
9).加载视图:在定义controller的时候需多添加一个$ionicLoading服务
10).开始加载:$ionicLoading.show({
template: 'Loading...'
});
11).停止加载:$ionicLoading.hide();
12).下拉刷新:ion-refresher
13).定义刷新的时候显示的标题:pulling-text="正在刷新..."
14).下拉刷新的时候出发的方法:on-refresh=""
15)..finally(function() {
// 停止广播ion-refresher
$scope.$broadcast('scroll.refreshComplete');
});