14.4. 引入模块并使用服务
结合上面的“定义模块”和“定义服务”,我们可以方便地组织自己的额外代码:
- angular.module('MyModule', [], function($provide){
$provide.factory('S1', function(){
return 'I am S1';
});
$provide.factory('S2', function(){
return {see: function(){return 'I am S2'}}
});
});
var app = angular.module('Demo', ['MyModule'], angular.noop);
app.controller('TestCtrl', function($scope, S1, S2){
console.log(S1)
console.log(S2.see())
});