angularJs之模块化

时间:2023-11-22 16:17:56

<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script>

/*var m1 = angular.module('myApp',[]);
m1.controller('Aaa',function($scope){
$scope.name = 'hello';
});
m1.controller('Bbb',function($scope){
$scope.name = 'hi';
});*/

var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope',function($scope){
$scope.name = 'hello';
}]);
m1.controller('Bbb',['$scope',function($scope){
$scope.name = 'hi';
}]);

/*
function Aaa($scope){
$scope.name = 'hello';
}
function Bbb($scope){
$scope.name = 'hi';
}*/

</script>
</head>

<body>
<div ng-controller="Aaa">
<p>{{name}}</p>
</div>
<div ng-controller="Bbb">
<p>{{name}}</p>
</div>

</body>
</html>

angularJs之模块化