angularjs - AngularJS没有加载
问题描述
- HTML代码如下
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.7/angular.min.js"></script>
<meta charset="utf-8">
<title>ng-cribs</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap.min.js"></script>
<script src="app.js"></script>
<script src="scripts/cribsController.js"></script>
</head>
<body ng-app="ngCribs" ng-controller = "cribsController">
<h1>{{ hello }}</h1>
</body>
</html>
02.app.js 文件
angular.module('ngCribs',['ui.boostrap']);
03.cribsController.js 文件
angular
.module('ngCribs')
.controller('cribsController', function($scope){
$scope.hello = 'Hellow world';
});
问题
索引文件加载为{{ hello }}
Hellow 世界
解决方案
您可能需要$scope
像这样注入控制器:
angular
.module('ngCribs')
.controller('cribsController', ["$scope", function($scope){
$scope.hello = 'Hellow world';
}]);
推荐阅读
- python - 如何在函数中使用变量横向 yaml 文件?
- javascript - Karma - Jasmine,未处理的承诺拒绝:错误:无法加载“util”
- vue.js - vue 弹出输入自动获取焦点
- reactjs - 数据更新中减速器返回未定义
- heroku - Heroku MERN 部署。错误:找不到模块
- node.js - Quasar QStepper keep-alive不在垂直模式下工作
- linux - systemd 服务未重定向到不同的日志文件
- r - rpy2 和 R 的 curl.so 导致 libopenssl 错误
- rust - 变量即使没有被执行也会被移到闭包
- javascript - 当我调用一次时,我的减速器被触发了两次。当我尝试修复它时有一些奇怪的东西