我是Ionic的新手,我想要实现的是将不同的非静态信息呈现在手风琴中,该手风琴显示或出现在按钮上。问题是每个项目都会显示不同的信息,我需要为图像添加更多内容。
我可以在每行内显示模板还是只显示纯文本?我怎样才能显示更多文字?
因为信息在控制器的组数组中......所以我不知道该怎么做。
我只是从这里举起手风琴的例子...... http://codepen.io/anon/pen/zxJvxJ
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 Accordion</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-controller="MyCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Accordion 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.title}}
</ion-item>
<div ng-show="isGroupShown(group)">
<ion-item ng-repeat="content in group.contents" class="item-accordion">
<a href="">{{content.line}}</a>
</ion-item>
</div>
</div>
</ion-list>
</ion-content>
</body>
CSS ..
body {
cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
/*
* http://docs.angularjs.org/api/ng/directive/ngShow#usage_animations
*/
.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 = [{
title: "INTRODUCTION",
contents: [
{
line: "DONT BE AFRAID"
},
{
line: "WHY, WHAT & WHO"
},
{
line: "PITCH OR PRESENT"
},
{
line: "GREAT PRESENTATIONS"
}
]
},
{
title: "PREPARATION",
contents: [
{
line: "WHY?"
},
{
line: "WHAT IS THE MESSAGE?"
},
{
line: "WHAT IS THE VEHICLE?"
},
{
line: "WHO ARE THE AUDIENCE?"
}
]
},
{
title: "PITCH STRUCTURE",
contents: [
{
line: "BLAH"
},
{
line: "BLAH"
},
{
line: "BLAH"
},
{
line: "BLAH"
},
{
line: "BLAH"
},
{
line: "BLAH"
},
{
line: "BLAH"
}
]
}
];
/*
* if given group is the selected group, deselect it
* else, select the given group
*/
$scope.toggleGroup = function(group) {
if ($scope.isGroupShown(group)) {
$scope.shownGroup = null;
} else {
$scope.shownGroup = group;
}
};
$scope.isGroupShown = function(group) {
return $scope.shownGroup === group;
};
});
所以如果有人能指出我现在正确的道路,那就太好了。
非常感谢!