如何使用UI Bootstrap?

时间:2015-09-07 11:56:49

标签: javascript html angularjs twitter-bootstrap user-interface

我一直在互联网上搜索如何在AngularJS中使用UI Bootstrap,但我不会工作。

这是我现在的代码:

<html>
<head>
<script src="componenten/bower_components/angular/angular.js"></script>
<script src="componenten/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
<script src="componenten/bower_components/angular-bootstrap/ui-bootstrap.min.js"></script>
</head>
<body ng-app="ui.bootstrap.demo">
<div ng-controller="ModalDemoCtrl">
    <script type="text/ng-template" id="myModalContent.html">
        <div class="modal-header">
            <h3 class="modal-title">I'm a modal!</h3>
        </div>
        <div class="modal-body">
            <ul>
                <li ng-repeat="item in items">
                    <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
                </li>
            </ul>
            Selected: <b>{{ selected.item }}</b>
        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
            <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
        </div>
    </script>
    <button type="button" class="btn btn-default" ng-click="open()">Open me!       </button>
    <button type="button" class="btn btn-default" ng-click="open('lg')">Large modal</button>
    <button type="button" class="btn btn-default" ng-click="open('sm')">Small modal</button>
    <button type="button" class="btn btn-default" ng-click="toggleAnimation()">Toggle Animation ({{ animationsEnabled }})</button>
    <div ng-show="selected">Selection from a modal: {{ selected }}</div>
    </div>
</body>
</html>

我已经尝试添加几乎所有脚本和css文件,但它永远不会工作。

1 个答案:

答案 0 :(得分:3)

您需要将Angular Bootstrap作为依赖项包含在内:

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

请删除包含代码和模板的ui-bootstrap.min.js beacuse ui-bootstrap-tpls.min.js