<!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('module1',[]);
// m1.factory('myService',function (){
// return{
// name:'hello',
// show:function(){
// return this.name + ':angular';
// }
// };
// });
m1.provider('myService',function(){
return{
name:'hello',
$get:function(){
return{
name:this.name,
show:function(){
return this.name + ':angular'
}
}
}
}
})
var m2 = angular.module('myApp',['module1']);
m2.controller('Aaa',['$scope','myService',function($scope,myService){
console.log(myService.show())
}])
</script>
</head>
<body>
<div ng-controller="Aaa">
</div>
</body>
</html>