I'm getting quite crazy here... I'm trying to use Bootstraps collapse functionality (https://angular-ui.github.io/bootstrap/#/collapse). I'm new to AngularJS. I get the error "Module 'myapp' is not available!". I can't seem to find what's wrong with this code:
我在这里变得非常疯狂......我正在尝试使用Bootstraps折叠功能(https://angular-ui.github.io/bootstrap/#/collapse)。我是AngularJS的新手。我收到错误“模块'myapp'不可用!”。我似乎无法找到这段代码的错误:
<html>
<head></head>
<body>
<script type="text/javascript" src="/js/angular.js"></script>
<script type="text/javascript" src="/js/ui-bootstrap-tpls-0.13.2.min.js"></script>
<script>
angular.module('myapp').controller('CollapseDemoCtrl', function ($scope) {
$scope.isCollapsed = false;
});
</script>
<div ng-app="myapp">
<div ng-controller="CollapseDemoCtrl">
<button type="button" class="btn btn-default" ng-click="isCollapsed = !isCollapsed">Toggle collapse</button>
<hr>
<div collapse="isCollapsed">
<div class="well well-lg">Some content</div>
</div>
</div>
</div>
</body>
</html>
Thank you!
谢谢!
1 个解决方案
#1
4
In Angular the syntax for declaring a module is as below, where the modules dependencies are listed in the brackets.
在Angular中,声明模块的语法如下所示,其中模块依赖项列在括号中。
angular.module('myapp', [])
When you want to retrieve a reference to the module, you do this - note how this time the brackets are not used.
如果要检索对模块的引用,请执行此操作 - 请注意此时未使用括号的方式。
angular.module('myapp')
You need to change your code so that it is like this:
您需要更改代码,使其如下所示:
angular.module('myapp', []).controller('CollapseDemoCtrl', function ($scope) {
$scope.isCollapsed = false;
});
Plunker here: http://plnkr.co/edit/?p=preview
Plunker:http://plnkr.co/edit/?p = preview
#1
4
In Angular the syntax for declaring a module is as below, where the modules dependencies are listed in the brackets.
在Angular中,声明模块的语法如下所示,其中模块依赖项列在括号中。
angular.module('myapp', [])
When you want to retrieve a reference to the module, you do this - note how this time the brackets are not used.
如果要检索对模块的引用,请执行此操作 - 请注意此时未使用括号的方式。
angular.module('myapp')
You need to change your code so that it is like this:
您需要更改代码,使其如下所示:
angular.module('myapp', []).controller('CollapseDemoCtrl', function ($scope) {
$scope.isCollapsed = false;
});
Plunker here: http://plnkr.co/edit/?p=preview
Plunker:http://plnkr.co/edit/?p = preview