angular.js 1.4.8错误:$ resource:badcfg。普通浏览器中存在错误但未隐身

时间:2016-09-01 12:54:15

标签: javascript angularjs

页面加载后,我从Angular得到以下错误:

angular.js:12520 Error: [$resource:badcfg] http://errors.angularjs.org/1.4.8/$resource/badcfg?p0=query&p1=array&p2=object&p3=GET&p4=%2Fapi%2Fprospects%2Factive
    at Error (native)
    at http://localhost:3807/Scripts/angular/angular.min.js:6:416
    at k.then.p.$resolved (http://localhost:3807/Scripts/angular/angular-resource.min.js:9:408)
    at http://localhost:3807/Scripts/angular/angular.min.js:119:129
    at r.$eval (http://localhost:3807/Scripts/angular/angular.min.js:133:313)
    at r.$digest (http://localhost:3807/Scripts/angular/angular.min.js:130:412)
    at r.$apply (http://localhost:3807/Scripts/angular/angular.min.js:134:78)
    at g (http://localhost:3807/Scripts/angular/angular.min.js:87:444)
    at T (http://localhost:3807/Scripts/angular/angular.min.js:92:50)
    at XMLHttpRequest.w.onload (http://localhost:3807/Scripts/angular/angular.min.js:93:78)

我怀疑错误来自下面自动调用的query方法:

define(['ngResource'], function () {
    'use strict';
    prospectResource.$inject = ['$resource'];
    return prospectResource;

    function prospectResource($resource) {
        var controllerPath = '/api/prospects/';

        var actions = $resource(controllerPath, {}, {
            query: {
                method: 'GET',
                url: controllerPath + 'active',
                isArray: true,
                Cache: true
            },
            all: {
                method: 'GET',
                url: controllerPath + 'all',
                isArray: true,
            },
            convert: {
                method: 'POST',
                url: controllerPath + 'convert/:prospectId'
            }
        });

        return actions;
    }
});

奇怪的是,错误仅发生在Chrome中的非隐身模式中,而不是隐身模式中。然后我尝试做“清空缓存和硬重载”,重新启动Chrome,清除cookie等但没有任何作用。可能是什么导致了这个?我在想它是否可能是一些插件,但我尝试禁用Ad-blocker等但我仍然得到相同的结果。在Incognito中一切正常。

Angular版本是1.4.8

1 个答案:

答案 0 :(得分:0)

问题与cookie有关。在Chrome中,转到Settings -> Show advanced settings… -> "Clear browsing data…" -> the beginning of time -> mark everything -> Clear browsing data。一切都开始奏效了。