angular.js--demo2-----声明局部控制器controller

<!doctype html>
<html ng-app="HelloAngular">
<head>
<meta charset="utf-8">
</head>
<body>
<div ng-controller="helloAngular">
<p>{{greeting.text}},angular-demo2</p>
</div>
</body>
<script src="js/angular-1.3.0.js"></script>
<script src="HelloAngular_Module.js"></script>
</html>

HelloAngular_Module.js

var myModule= angular.module("HelloAngular",[]);
myModule.controller("helloAngular",['$scope',
function hell ($scope){
$scope.greeting = {
text:'你好'
};
}

]);

原文地址:https://www.cnblogs.com/qiyc/p/5958062.html