创建多模块

2018-02-09 19:17:00
admin
原创
332
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script> 
</head>
<body ng-app="myApp">
	
<div ng-controller="myCtrl">
myCtrl作用域:{{ firstName + " " + lastName }}
</div>

<div ng-controller="myCtrl1">
myCtrl1作用域:{{ firstName + " " + lastName }}
</div>
	
<div ng-controller="myCtrl2">
myCtrl2作用域:{{ firstName + " " + lastName }}
</div>

</body>
	
<script>
	
var app = angular.module("myApp", ["myApp.myCtrl1","myApp.myCtrl2"]);
app.controller("myCtrl", function($scope) {
    $scope.firstName = "John";
    $scope.lastName = "Doe";
}
			  );
	
var app1 = angular.module("myApp.myCtrl1", []);
app1.controller("myCtrl1", function($scope) {
    $scope.firstName = "John1";
    $scope.lastName = "Doe1";
});

var app2 = angular.module("myApp.myCtrl2", []);
app2.controller("myCtrl2", function($scope) {
    $scope.firstName = "John2";
    $scope.lastName = "Doe2";
});
	
</script>
	
</html>
				
				
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227