我正在尝试使用Bootstrap和angular.js运行ui.bootstrap.tabs示例代码。 html代码在aspx中,我使用.net framework 3.5
example.js有:
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function($scope) {
$scope.tabs = [
{ title: 'Dynamic Title 1', content: 'Dynamic content 1' },
{ title: 'Dynamic Title 2', content: 'Dynamic content 2', disabled: true }
];
$scope.alertMe = function() {
setTimeout(function() {
alert('You\'ve selected the alert tab!');
});
};
});
HTML部分:
<link href="css/bs/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<div ng-controller="TabsDemoCtrl">
Select a tab by setting active binding to true:
<button class="btn btn-default btn-sm" ng-click="tabs[0].active = true">Select second
tab</button>
<button class="btn btn-default btn-sm" ng-click="tabs[1].active = true">Select third
tab</button>
<button class="btn btn-default btn-sm" ng-click="tabs[1].disabled = ! tabs[1].disabled">Enable /
Disable third tab</button>
<script src="jsNew/example.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js" type ="text/javascript">
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.2.js" type ="text/javascript">
当我运行时,我得到错误Microsoft JScript运行时错误:'angular'未定义指向example.js的第一行。请帮助一下,我缺少哪个指令。或者有人可以给我一个样品。我只是想使用bootstrap和angularjs创建选项卡。没有使用angular和bootstrap。提前谢谢。
答案 0 :(得分:0)
在示例.js之后包含了角度,因此在尝试使用时不会定义角度。您需要按顺序包含所有依赖项,并确保关闭脚本标记。将example.js移到角度以下,你应该好好去!
<script src="jsNew/example.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js" type="text/javascript">
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.2.js" type="text/javascript">
应该是:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js" type="text/javascript"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.2.js" type="text/javascript"></script>
<script src="jsNew/example.js" type="text/javascript"></script>