Bootstrap UI Свернуть открыт по умолчанию

0

У меня возникла проблема с директивой bootstrap ui collapsed, она отображается как по умолчанию, и мне нужно было рухнуть при загрузке страницы, я правильно устанавливаю переменные, но все еще не работает правильно

здесь часть моего кода:

aside class="col-md-3 leftSidebar separator-right" ng-controller="Collapse as vm">
<div class="row separator">
    <div class="sidebarPosition">
        <div class="leftSidebar__toggle">
            <a class="mod" ng-click="vm.isCollapsedLeft = !vm.isCollapsedLeft"><span class="fa fa-bars"></span> Outline</a>

            <ul uib-collapse="vm.isCollapsedLeft">
                <li><a href="#scientific_abstract" du-smooth-scroll>Scientific Abstract</a></li>
                <li><a href="#layperson_abstract" du-smooth-scroll>Laypersons Abstract</a></li>
                <li><a href="#introduction" du-smooth-scroll>Introduction</a></li>
                <li><a href="#">Results</a></li>
                <li><a href="#">Discussion</a></li>
                <li><a href="#">Methods</a></li>
                <li><a href="#">Additional Information</a></li>
                <li><a href="#">Change History</a></li>
                <li><a href="#">Acknowledgements</a></li>
                <li><a href="#">Author Information</a></li>
                <li><a href="#">Author Contributions</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="row leftSidebar__sections">
    <ul>
        <li><a ui-sref="article.figures"><span class="fa fa-picture-o"></span> Figures</a></li>
        <li><a ui-sref="article.references"><span class="fa fa-link"></span> References</a></li>
        <li><a href="#"><span class="fa fa-retweet"></span> Related</a></li>
        <li>
            <a href="#"> <span class="fa fa-area-chart"></span> Stats Impact</a>
        </li>
        <li><a ui-sref="article.comments"><span class="fa fa-comment"></span> Comments</a></li>
    </ul>
</div>
</aside>

мой контроллер:

(function () {
'use strict';

angular
    .module('app.bootstrap')
    .controller('Collapse', Collapse);

function Collapse() {

    var vm = this;

    vm.isCollapsedLeft = false;
    vm.isCollapsedRight = false;

}

})();

и здесь plunkr: https://plnkr.co/edit/D0vFMEQe4a2GT1yJLTLk?p=preview

Спасибо за помощь.

  • 0
    планкр сейчас работает
Теги:
angular-ui-bootstrap

2 ответа

1
Лучший ответ

Вы сказали, что хотите, чтобы он упал при загрузке страницы, но вы устанавливаете vm.isCollapsedLeft = false; , Установите vm.isCollapsedLeft = true; и он будет сбрасываться при загрузке страницы.

  • 0
    Вы правы, я пытался это, но это не сработало, я чувствую себя глупо, хахаха
0

<html >
<head>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<style class="cp-pen-styles">.panel-heading .accordion-toggle:after {
    /* symbol for "opening" panels */
    font-family: 'Glyphicons Halflings';  /* essential for enabling glyphicon */
    content: "\e114";    /* adjust as needed, taken from bootstrap.css */
    float: left;        /* adjust as needed */
    color: grey;         /* adjust as needed */
}
.panel-heading .accordion-toggle.collapsed:after {
    /* symbol for "collapsed" panels */
    content: "\e080";    /* adjust as needed, taken from bootstrap.css */
}
</style>

</head>
<body>
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<div class="container">

  
  <div class="panel-group" id="accordion" aria-multiselectable="true" >
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle" data-toggle="collapse"  href="#collapseOne" >
          Collapsible Group Item #1
        </a>
      </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in">
      <div class="panel-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle" data-toggle="collapse"  href="#collapseTwo" >
          Collapsible Group Item #2
        </a>
      </h4>
    </div>
    <div id="collapseTwo" class="panel-collapse collapse in" >
      <div class="panel-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle" data-toggle="collapse" href="#collapseThree" aria-expanded="false">
          Collapsible Group Item #3
        </a>
      </h4>
    </div>
    <div id="collapseThree" class="panel-collapse collapse in" >
      <div class="panel-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>
  
  
</div> <!-- end container -->

<!-- Latest compiled and minified JavaScript -->

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

</body></html>

Ещё вопросы

Сообщество Overcoder
Наверх
Меню