angular $ Resource返回一个html数组作为响应。为什么?

时间:2017-06-16 13:25:57

标签: angularjs ngresource

$ Resource返回一个html数组作为响应 我究竟做错了什么?

angular.module('userService', ['ngResource'])
.factory('serviceResource', function ($resource) {
    return $resource('/user/:login', null, {
        login: '@',
        'update': {
            method: 'PUT'
        },
        'query': {
            method: 'GET',
            isArray: false
        }
    });
})

.factory('userFactory', function (serviceResource, $q) {
    var service = {};
    service.login = function (email) {
        return $q(function (resolve, reject) {
            serviceResource.get({login: email}, function (data) {
                console.log(data);
                resolve(data);
            }, function (error) {

                reject({
                    message: 'Não foi possível buscar os dados do usuário.',
                    error: error
                });
            });
        });
    };

    return service;
});

Image with the answer

它应该返回一个包含信息的对象。

0 个答案:

没有答案