码迷,mamicode.com
首页 > Web开发 > 详细

AngularJs练习Demo13Provider_factory

时间:2016-06-22 00:13:54      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

 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>

 

AngularJs练习Demo13Provider_factory

标签:

原文地址:http://www.cnblogs.com/sumg/p/5605367.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!