angular实现多个div的展开和折叠


代码:

<body ng-app="app">
    <ul ng-controller="myCtrl" style="list-style:none;">
        <li ng-repeat="li in list track by $index" style="margin:5px;">
            <div style="background:#f38f8f;width:150px;height:30px;line-height:30px;color:#fff;" ng-click="show($index)">我是标题</div>
            <div style="background:#ccc;width:150px;height:50px;" ng-show="li.show">我是内容</div>
        </li>
    </ul>

<script type="text/javascript">
    var app=angular.module('app', []);
    app.controller('myCtrl',function($scope){
        $scope.list=[
            {show:'true'},
            {show:'true'},
            {show:'true'},
            {show:'true'}
        ];
        $scope.show=function($index){
            $scope.list[$index].show=!$scope.list[$index].show;
        }
    })
</script>
</body>

如图:


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM