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(); })