<!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 world
答案 0 :(得分:-1)
您可能需要像这样将$scope
注入控制器:
angular
.module('ngCribs')
.controller('cribsController', ["$scope", function($scope){
$scope.hello = 'Hellow world';
}]);