Simon Trewhella Simon Trewhella - 4 months ago 21
AngularJS Question

Angular UI Bootstrap collapse - whats wrong?

I can't seem to get angular ui bootstraps collapse directive to work. I've set up a plunkr with a minimal example, but its still non functional. Anyone shed any light on this?

Plunkr

HTML

<!DOCTYPE html>
<html ng-app="app">

<head>
<link data-require="bootstrap-css@3.1.*" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<script data-require="angular.js@*" data-semver="1.3.7" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js"></script>
<script data-require="ui-bootstrap@*" data-semver="0.12.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>

<body ng-controller="CollapseController">
<button class="btn btn-default" ng-click="collapsed = !collapsed">Toggle</button>
<div collapse="collapsed">
<div>
<h1>Hello Plunker!</h1>
</div>
</div>
</body>

</html>


JS

angular.module('app', [])
.controller('CollapseController', function($scope){
$scope.collapsed = false;
});

Answer

You should declare a dependency in your app module on ui.bootstrap module:

angular.module('app', ['ui.bootstrap']);

Here's your updated working plnkr.

Comments