<body ng-app="myApp" class="body">
<div ng-controller="AccordionDemoCtrl">
<div ng-repeat="info in panelShow">
<h2 ng-click="openCon($index)">{{info.title}}</h2>
<!--ng-class="{'active':info.status}"-->
<section class="con" ng-if="info.status">{{info.infoBox}}</section>
</div>
</div>
</body>
<script>
var App = angular.module('myApp', []);
App.controller('AccordionDemoCtrl', function ($scope) {
$scope.panelStatus = false;
var mySomething = [
{
title:'UI设计',
infoBox:'至少你要会画画吧'
},
{
title:'web程序员',
infoBox:'至少你要会写代码吧'
},
{
title:'产品狗狗',
infoBox:'至少你要会思考吧'
}
];
$scope.panelShow = mySomething;
angular.forEach($scope.panelShow,function(i){
i.status = false
});
// var newPanel = $scope.panelShow;
$scope.openCon =function(idx){
// 只打开唯一一个:
// if($scope.panelShow[idx].status == false){
// angular.forEach($scope.panelShow,function(i){
// i.status = false
// });
// }
$scope.panelShow[idx].status = !$scope.panelShow[idx].status;
}
});
</s