2017-02-21 87 views
5

任何人都可以给出有关添加展开/折叠视图here的任何建议。 我想只使用AngularJS和AngularJS,而不是依赖于Bootstrap等,但我找不到任何适合AngularMaterial文档的东西。使用斜角材料展开折叠列表项目

谢谢

+0

您是否试过我的解决方案? – nextt1

回答

1

这似乎并没有使用引导程序。

https://github.com/LukaszWatroba/v-accordion

这应该是可能的代码,以使自己的手风琴与材料

http://blog.sodhanalibrary.com/2016/02/accordion-with-angularjs-material-ui.html#.WKxqI1UrJaQ

+0

您是否知道是否存在仅使用AngularMaterial的示例?在这个阶段,我无法添加额外的库。 – Adam

+0

是的,这就是对的。它没有完成材料。这一个更有帮助吗? http://blog.sodhanalibrary.com/2016/02/accordion-with-angularjs-material-ui.html#.WKxqI1UrJaQ –

8

一种方法是使用连续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

+0

要为展开/折叠过渡设置动画,您可以考虑使用[ngAnimate](https:// docs .angularjs.org /导向/动画)。向隐藏元素添加'section-show-hide'类非常简单,并且此css代码: '.section-show-hide {0}转换:全部为线性0.5s; max-height:500px; } .section-show-hide.ng-hide {opality:0; } max-height:0; }' – Wiil