首页 > 解决方案 > AngularJS没有加载

问题描述

  1. 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 世界

标签: angularjs

解决方案


您可能需要$scope像这样注入控制器:

angular
    .module('ngCribs')
    .controller('cribsController', ["$scope", function($scope){
        $scope.hello = 'Hellow world';
    }]);

推荐阅读