标签:
在angular中将http请求,放置在一起封装成服务,可减少代码重复,方便使用
var ngpohttprest = angular.module(‘ngpohttprest‘, []); ngpohttprest.factory(‘httpItemCore‘, function ($http, $q) { return { search: function (params) { var defer = $q.defer(); $http({ method: ‘get‘, params: params, url: ‘/MGCode/Item/ItemCoreInfo‘ }).success(function (data) { defer.resolve(data); }).error(function (data) { defer.reject(data); }); return defer.promise } }; });
标签:
原文地址:http://www.cnblogs.com/CoreXin/p/5622141.html