https://meilishiyan-song.taobao.com/

angularJs之模块化

<!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>

 

posted @ 2016-12-20 20:30  望梦圆  阅读(280)  评论(0编辑  收藏  举报
https://meilishiyan-song.taobao.com/