1 @{
2 Layout = null;
3 }
4
5 <!DOCTYPE html>
6
7 <html>
8 <head>
9 <meta name="viewport" content="width=device-width" />
10 <title>Provider</title>
11 <script type="text/javascript" src="~/Scripts/angular.js"></script>
12 <script type="text/javascript">
13 var myApp = angular.module("myApp", [], function ($provide) {
14 $provide.provider('providerServices01', function () {//自定义服务,通过module的第三个参数来定义
15 this.$get = function () {
16 return {
17 message: 'this is providerServices01'
18 }
19 }
20 });
21 $provide.factory("factoryServies01", function () {
22 return {
23 message: "this is factoryServies01"
24 }
25 });
26
27 $provide.service("serviceServies01", function () { //只能返回对象
28 return {
29 message: "this is serviceServies01"
30 }
31 });
32
33 });
34 myApp.controller("firstController", ["$scope", "factoryServies01", function ($scope, factoryServies01) {
35
36 }]);
37
38 </script>
39
40 </head>
41 <body>
42 <div ng-app="myApp">
43 <div ng-controller="firstController">
44
45
46 </div>
47 </div>
48 </body>
49 </html>