angularjs发起put请求示例

        //用户登录
        postLogin : function(params) {
            params['_method'] = 'PUT';
            console.log(params);
            var deferred = $q.defer();
            var url = config.basePath  + 'admins/1.html?act=login';
            $http({
                method: 'POST',
                url: url,
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                transformRequest: function (obj) {
                    var str = [];
                    for (var o in obj)
                        str.push(encodeURIComponent(o) + "=" + encodeURIComponent(obj[o]));
                    return str.join("&");
                },
                data: params
            }).success(
                function (data, status, header, config) {
                    deferred.resolve(data);
                });
            return deferred.promise;
        },

你可能感兴趣的:(angularjs发起put请求示例)