twitter bootstrap accordion effect not working for menu

后端 未结 2 1002
深忆病人
深忆病人 2021-01-28 09:52

I have parent menu with sub menus, but the accordion effect is not working for menus.(if second menu link clicks, automatically the first menu should close)

I have creat

相关标签:
2条回答
  • 2021-01-28 10:43

    finally its working fine with small change,

    <div id="sidebar-wrapper">
        <div id="accordion">
          <ul class="panel sidebar-nav" ng-repeat="item in model | orderBy:'sortOrder'" id="sidebar{{$index}}">
            <li>
              <a href="javascript:void(0)" class="mainMenu menuArrow collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#child{{$index}}" ng-click="model.selected = item">{{item.description}}
                 <i class="sub_icon fa fa-lg fa-fw {{item.iconTarget}}"></i>
              </a>
            </li>
            <li id="child{{$index}}" data-menu-title="{{item.description}}" ng-class="{'collapse':true}">
              <ul>
                <li ng-repeat="subitem in item.children">
                 <a href="#{{subitem.target}}" class="subTitle"> {{subitem.description}} </a>
                </li>
              </ul>
            </li>
         </ul>
        </div>
    </div>  
    
    0 讨论(0)
  • 2021-01-28 10:45

    back, (after a hard day...) and as promise :

    • better than ng-Class (like I said earlier), I suggest Angular UI (Twitter Bootstrap written natively in AngularJS)

      <!doctype html>
      <html ng-app="ui.bootstrap.demo">
       <head>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
       <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.1.js"></script>
       <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
      
      
      <script>
      
      //here in your javascript file (here is a demo)    
      angular.module('ui.bootstrap.demo', ['ui.bootstrap']);     
      angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) {
      
      
      $scope.oneAtATime = true;
      
          $scope.model = [
            {
                "code": "401",
                "description": "Transactions",
                "labelName": null,
                "target": null,
                "children": [
                    {
                        "description": "Deposit Funds",
                        "target": "transds",
                        "children": null
                    },
                    {
                        "description": "Withdraw Funds",
                        "target": "fdfdfs",
                        "children": null
                      }
                  ]
               },
              {
                "code": "403",
      
                   "description": "Cash Management",
                   "labelName": null,
                   "target": null,
                   "children": [
                     {
                           "description": "Head Cashier - Entry",
                           "target": "ccry.html",
                           "children": null
                    },
                    {
                        "description": "Head Cashier - Verify",
                        "target": "ccg.html",
                        "children": null
                    }
                ]
            }
         ];
      
      });      
      
       </script>
      
      
      </head>
      <body>
      
      <div ng-controller="AccordionDemoCtrl">
      <label class="checkbox">
      <input type="checkbox" ng-model="oneAtATime">
        Open only one at a time
      </label>
      <p>Example amazing angular accordion</p>
      
      
      
       <accordion close-others="oneAtATime" >
         <div ng-repeat="item in model | orderBy:'sortOrder'">
         <accordion-group>
           <accordion-heading>
             {{item.description}} <i class="sub_icon fa fa-lg fa-fw {{item.iconTarget}}"></i>
           </accordion-heading>
      
           <div ng-repeat="subitem in item.children">
               <a href="#{{subitem.target}}" class="subTitle"> {{subitem.description}} </a>
           </div>
         </accordion-group>
         </div>
       </accordion>
      
      
       </div>
       </body>
      </html>
      
    • Next I let you apply your own css and move js in a file.

    0 讨论(0)
提交回复
热议问题