angularjs service

 angular.module('app', [])
            .value("a", "123")             //可改
            .constant("b", "456")       //不可改
            .factory("c", function () {
                return {
                    name: "段誉",
                    setname: function () {
                    this.name = "";
                    }
                }
            })
            .service("d", function () {
                this.firstn = "西门";
                this.lastn = "吹雪";
                this.getname = function () {
                    return this.firstn + this.lastn;
                }
            })
        .controller('ctrl', function ($scope,a,b,c,d) {
            $scope.a = a;
            $scope.b = b;
            $scope.c = c;
            c.setname();
            $scope.d = d.getname();
        })

 

posted on 2018-03-16 15:37  段了的弦  阅读(111)  评论(0编辑  收藏  举报