有人能给出如何添加展开/折叠视图的建议吗?参见这里。 我想只使用AngularJS的Angular Material,而不依赖于Bootstrap等库。然而在AngularMaterial文档中找不到合适的内容。
谢谢
有人能给出如何添加展开/折叠视图的建议吗?参见这里。 我想只使用AngularJS的Angular Material,而不依赖于Bootstrap等库。然而在AngularMaterial文档中找不到合适的内容。
谢谢
一种方法是使用连续的 2 个 md-list-item
。
以下是 HTML 代码。
<md-list flex>
<md-list-item ng-click="toggle.list1 = !toggle.list1">
<md-icon>explore</md-icon>
<span flex>Item List 1</span>
<md-icon ng-show="!toggle.list1">expand_more</md-icon>
<md-icon ng-show="toggle.list1">expand_less</md-icon>
</md-list-item>
<md-list-item ng-repeat="item in data" ng-show="toggle.list1">
<span flex-offset="5">{{item}}</span>
</md-list-item>
<md-list-item ng-click="toggle.list2 = !toggle.list2">
<md-icon>explore</md-icon>
<span flex>Item List 2</span>
<md-icon ng-show="!toggle.list2">expand_more</md-icon>
<md-icon ng-show="toggle.list2">expand_less</md-icon>
</md-list-item>
<md-list-item ng-repeat="item in data" ng-show="toggle.list2">
<span flex-offset="5">{{item}}</span>
</md-list-item>
</md-list>
JS 代码:
angular.module('myApp',['ngMaterial'])
.controller('TempController', function($scope){
$scope.data = [ "Item 1", "Item 2", "Item 3", "Item 4"]
$scope.toggle = {};
});;
这里是可工作的Codepen。
https://github.com/LukaszWatroba/v-accordion
这应该是使用 Material 可以制作自己的手风琴代码。http://blog.sodhanalibrary.com/2016/02/accordion-with-angularjs-material-ui.html#.WKxqI1UrJaQ
section-show-hide
类添加到隐藏元素中,并添加以下CSS代码即可:.section-show-hide { transition: all linear 0.5s; max-height: 500px; } .section-show-hide.ng-hide { opacity: 0; max-height: 0; }
- Wiil