angularjs Angular UI-引导程序-折叠功能不工作

ajsxfq5m  于 2022-11-28  发布在  Angular
关注(0)|答案(1)|浏览(120)

我一直在关注docs for ui-bootstrap。在(ui.bootstrap.collapse)一节中,他们谈到了当你点击按钮时为内容制作一个折叠函数。
但是我似乎无法使Collapse在我的代码中工作。
我错过了什么或做错了什么?
我看过其他的堆栈,也看到其他人使用锚标签而不是按钮标签,所以我不认为这是问题所在。

索引HTML

<!DOCTYPE html>
<html lang="en" data-ng-app="app">
<head>
<meta charset="UTF-8">
<meta name="description" content="stuff">
<meta name="keywords" content="stuff">
<meta name="author" content="stuff">

<title> Title</title>

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.css">

<!-- Custom styles -->
<link href="css/style.css" rel="stylesheet">
<link href="css/svg_style.css" rel="stylesheet">

<!--Jquery -->
<script src="lib/jquery/dist/jquery.min.js"></script>

<!-- Angular -->
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular-route/angular-route.min.js"></script>
<script src="lib/angular-animate/angular-animate.min.js"></script>
<script src="lib/angular-cookies/angular-cookies.min.js"></script>

<!-- Bootstrap -->
<script src="lib/angular-bootstrap/ui-bootstrap.min.js"></script>
<script src="lib/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>

</head>

<body id="index_body">
<div data-ng-controller="HeaderCtrl">
    <div class="top-header" data-ng-include="templateUrl"></div>
</div>

    <div class="page [[ pageClass ]]" ng-view autoscroll="true"></div>

<!-- Main JS -->
<script src="js/app.js"></script>

<!-- Controllers -->
<script src="js/controllers/headerCtrl.js"></script>
<script src="js/controllers/modal.js"></script>
<script src="js/controllers/ResonanceCtrl.js"></script>
<script src="js/controllers/ContactCtrl.js"></script>
<script src="js/controllers/LandingCtrl.js"></script>
<script src="js/controllers/SignInCtrl.js"></script>

<!-- Directives -->
<!-- <script src="js/directives/LandingAnimation.js"></script> -->

<script src="js/jq.js"></script>
</body>

</html>

登录页面HTML

<div class="col-xs-12 col-sm-12 col-md-5">
    <div class="caption">
         <h1 class="text-left h-color thin">
  Text Header
</h1>

        <p class="lead p-color">More Text</p>
        <!-- Here is my Toggle Button --> <a class="lead p-color learn-button togglebtn shake shake-rotate" data-ng-click="isCollapsed = !isCollapsed"> 
  <small>
  <i class="glyphicon" data-ng-class="{'glyphicon-minus': status.open, 'glyphicon-plus': !status.open}"></i> Learn More
  </small>
</a>

    </div>
</div>
<div class="hidden-xs hidden-sm col-md-7 col-lg-offset-1 col-lg-6">
    <img alt="Image" class="img-responsive center-block" src="images/kip-animation.png" />
</div>

<!--Here is the what I want to collapse -->
<div id="myContent" collapse="isCollapsed" class="row row-offset row-pad" style="margin: 0 30px">
    <div class="col-xs-6 col-sm-4 col-md-4">
        <div class="lead caption text-center">
             <h3 class="h-color2">Item 1</h3>

        </div>
        <div class="thumbnail">
            <img style="height: 100px; width: auto;" class="img-circle" src="images/logo-bunny.png" alt="Logo">
            </div>
        <div class="lead caption">
            <p class="p-color"><small>Text</small>
            </p>
        </div>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-4">
        <div class="lead caption text-center">
             <h3 class="h-color2">Item 2</h3>

        </div>
        <div class="thumbnail">
            <img style="height: 100px; width: auto;" class="img-circle" src="images/logo-bunny.png" alt="Logo">
        </div>
        <div class="lead caption">
            <p class="p-color"><small>Text</small>
            </p>
        </div>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-4">
        <div class="lead caption text-center">
             <h3 class="h-color2">Item 3</h3>

        </div>
        <div class="thumbnail">
            <img style="height: 100px; width: auto;" class="img-circle" src="images/logo-bunny.png" alt="Logo">
        </div>
        <div class="lead caption">
            <p class="p-color"> <small>Some Text</small>

            </p>
        </div>
    </div>
</div>
<!-- END DROPDOWN-->

应用程序Javascript

var app = angular.module('app', ['ui.bootstrap', 'ngRoute', 'ngAnimate']);

app.config(function($interpolateProvider, $routeProvider) {
  $interpolateProvider.startSymbol('[[');
  $interpolateProvider.endSymbol(']]');

  $routeProvider

    .when('/', {
      templateUrl : 'pages/LandingPage.html',
      controller : 'LandingCtrl'
  })
  .otherwise({ redirectTo: '/signin'});
});

控制器Javascript

app.controller('LandingCtrl', function($scope) { // jshint ignore:line
$scope.pageClass = 'page-landing';

$scope.isCollapsed = true;

});
rlcwz9us

rlcwz9us1#

我解决了这个问题。我之前使用Jquery来切换隐藏或显示的显示。
在我的CSS中,我有:

myContent {
  display: none;
}

一旦我删除了它。它工作得非常好。

相关问题