PhoneGap中文网
标题:
ionic list列表下的item可以做折叠吗?需要如何实现?
[打印本页]
作者:
abci
时间:
2015-7-22 02:25
标题:
ionic list列表下的item可以做折叠吗?需要如何实现?
ionic list列表下的item可以做折叠吗?需要如何实现?
要从数据库读取数据. item 展开->item下的子菜单->点击 ->另外的一个页面;
作者:
你懂的
时间:
2015-7-22 09:07
可以的吧 引入jquery就可以整 或者自己写个
作者:
abci
时间:
2016-7-13 18:26
写个指令来实现
作者:
神秘/yl星系
时间:
2017-9-6 10:31
我也有这个需求,麻烦给详细解说一下!感谢!!!
作者:
逍遥龙
时间:
2018-3-15 20:17
找到了,分享给大家
WEB-DEMO
html
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Ionic collapsible list</title>
<link href="//code.ionicframework.com/1.0.0-beta.12/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/1.0.0-beta.12/js/ionic.bundle.js"></script>
</script>
</head>
<body ng-controller="MyCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Ionic collapsible list</h1>
</ion-header-bar>
<ion-content>
<ion-list>
<div ng-repeat="group in groups">
<ion-item class="item-stable"
ng-click="toggleGroup(group)"
ng-class="{active: isGroupShown(group)}">
<i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
Group {{group.name}}
</ion-item>
<ion-item class="item-accordion"
ng-repeat="item in group.items"
ng-show="isGroupShown(group)">
{{item}}
</ion-item>
</div>
</ion-list>
</ion-content>
</body>
</html>
复制代码
css
.list .item.item-accordion {
line-height: 38px;
padding-top: 0;
padding-bottom: 0;
transition: 0.09s all linear;
}
.list .item.item-accordion.ng-hide {
line-height: 0px;
}
.list .item.item-accordion.ng-hide-add,
.list .item.item-accordion.ng-hide-remove {
display: block !important;
}
复制代码
js
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.groups = [];
for (var i=0; i<10; i++) {
$scope.groups[i] = {
name: i,
items: [],
show: false
};
for (var j=0; j<3; j++) {
$scope.groups[i].items.push(i + '-' + j);
}
}
/*
* if given group is the selected group, deselect it
* else, select the given group
*/
$scope.toggleGroup = function(group) {
group.show = !group.show;
};
$scope.isGroupShown = function(group) {
return group.show;
};
});
复制代码
欢迎光临 PhoneGap中文网 (http://bbs.phonegap100.com/)
Powered by Discuz! X3.2