我想为一组手风琴创建一个collpase / expand all按钮.我正在使用angular.js v1.2.6和angular-bootstrap-ui 0.9.0.我无法找到如何进行collpase / expand all的示例.我是一个有角度的新手,任何建议或意见表示赞赏.
原文链接:https://www.f2er.com/angularjs/240351.html另外,我应该补充一点,this post中的解决方案在我使用的较新版本的angular.js(v1.0.8 vs v1.2.6)中不起作用(这是此发布时的最新版本).在较新的版本中,它会抛出有关尝试创建两个隔离范围的错误.
标记:
<div ng-controller="myCtlr"> <accordion close-others="oneAtATime"> <button class="btn" ng-click="section.isCollapsed = !section.isCollapsed">Toggle Sections</button> <accordion-group ng-repeat="section in sections" is-open="section.isOpen"> <accordion-heading> <div class="accordion-heading-content" ng:class="{collapsed: section.isOpen}"> {{section.name}} </div> </accordion-heading> Section content </accordion-group> </accordion> </div>
JS:
var theapp = angular.module('myApp',[ 'ui.bootstrap' ]) function myCtlr ($scope) { $scope.isCollapsed = false; $scope.sections = [ {'id': '353','otherid': '7','name': 'One','Sequence': '1'},{'id': '354','otherid': '8','name': 'Two',{'id': '355','otherid': '9','name': 'Three','Sequence': '1'} ]; }