我正在尝试这个简单的教程来尝试UI Bootstrap:
https://scotch.io/tutorials/how-to-correctly-use-bootstrapjs-and-angularjs-together
但是我遇到了两个问题。
SyntaxError:预期的表达式,在ui-bootstrap-1.3.3.js:5:0处获得“
这是第一个问题。我尚未编辑文件中的任何内容,但它在第一行<!DOCTYPE html>
中说意外的令牌
另一个如下:
错误:[$ injector:modulerr]由于以下原因,无法实例化模块应用程序:
[$ injector:modulerr]由于以下原因,无法实例化模块ui.bootstrap:
[$ injector:nomod]模块'ui.bootstrap'不可用!您可能拼错了模块名称,或者忘记了加载它。如果注册模块,请确保将依赖项指定为第二个参数。
我看到了所有相关问题的答案,其中一些建议包括其他依赖项,而另一些建议确保依赖项的顺序。尝试了一切,但没有喜悦。
下面是我的html和js代码。请看一看
HTML
<html>
<head>
<style type="text/css">
@import "css/bootstrap.css";
@import "css/style.css";
</style>
<script src="js/angular.js"></script>
<script src="js/angular-animate.js"></script>
<script src="js/angular-touch.js"></script>
<script src="js/ui-bootstrap-1.3.3.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<div class="container" ng-app="app" ng-controller="mainController">
<div class="text-center">
<p>Example of Angular and the normal Bootstrap JavaScript components</p>
<p class="text-success">This will work</p>
</div>
<h2>Buttons</h2>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary" ng-model="bigData.breakfast" btn-checkbox>
Breakfast
</label>
<label class="btn btn-primary" ng-model="bigData.lunch" btn-checkbox>
Lunch
</label>
<label class="btn btn-primary" ng-model="bigData.dinner" btn-checkbox>
Dinner
</label>
</div>
<pre><code>{{ bigData | json }}</code></pre>
<h2>Collapse</h2>
<a href="#" class="btn btn-primary" ng-click="isCollapsed = !isCollapsed">
Toggle Panel
</a>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#" ng-click="isCollapsed = !isCollapsed">
Collapsible Group Item #1
</a>
</h4>
</div>
<div collapse="isCollapsed">
<div class="panel-body">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>
<pre><code>{{ isCollapsed }}</code></pre>
</div>
</body>
</html>
JS
angular.module('app', ['ngAnimate', 'ngTouch', 'ui.bootstrap'])
.controller('mainController', function($scope) {
// BUTTONS ======================
// define some random object
$scope.bigData = {};
$scope.bigData.breakfast = false;
$scope.bigData.lunch = false;
$scope.bigData.dinner = false;
// COLLAPSE =====================
$scope.isCollapsed = false;
});
不知道出了什么问题。
编辑
版本详细信息区域如下
Bootstrap v3.3.6
角度的
角动画
角接触
所有人都有AngularJS v1.5.3版本
最佳答案
确保ui-bootstrap-1.3.3
已正确加载到您的应用中。
请在下面找到工作的插头:
http://plnkr.co/edit/evG4XQ9ih9Cx0d1WF6YU?p=preview