AngularJs练习Demo14自定义服务

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Provider</title>
    <script type="text/javascript" src="~/Scripts/angular.js"></script>
    <script type="text/javascript">
        var myApp = angular.module("myApp", [], function ($provide) {
            $provide.provider('providerServices01', function () {//自定义服务,通过module的第三个参数来定义
                this.$get = function () {
                    return {
                        message: 'this is providerServices01'
                    }
                }
            });
        });
        myApp.controller("firstController", ["$scope", "providerServices01", function ($scope, providerServices01) {

        }]);

    </script>

</head>
<body>
    <div ng-app="myApp">
        <div ng-controller="firstController">


        </div> 
    </div>
</body>
</html>

 

posted @ 2016-06-21 23:08  编程猴子  阅读(193)  评论(0编辑  收藏  举报