var myHttp = angular.module('myHttp',[]); myHttp .service('httpServer',['$http',function($http){ this.myAjax = function(method,url,data,callBack){ //你的内部判断逻辑 } }]) var app = angular.module('app',['myHttp']) app.controller("appCtrl",['httpServer',function(httpServer){ //调用 httpServer.maAjax('GET','/user/123',function(data){ //你的操作 }) }])