0

次の問題があります: ページに ng-grid を表示するために ui-router を使用しています。しかし、 $resource は、サーバーに送信するときに URL からパラメーターを変更していません (例: http://bcuunix.test:8080/MYAPP/eq/:Id )。:Id は変更されず、:Id を送信しているため、サーバーから Bad request が返されます。

index.js

(function() {
'use strict';
var brgEquipments = angular.module('brg.equipments',
        [
            'ui.router',
            'brg.equipments.controllers'
        ]);
brgEquipments.config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/equipments/list');

    $stateProvider.state('list', {
        url: '/equipments/list',
        templateUrl: '/scripts/modules/equipments/views/grid_list.html',
        controller: 'equipmentsListCtrl',
        resolve: {
            // A string value resolves to a service
            eqService: 'eqService',
            // A function value resolves to the return
            // value of the function
            equipments: function(eqService) {
                return eqService.query().$promise;
            }
        }
    });

});

})();

service.js

(function() {
'use strict';
var eqCtrls = angular.module('brg.equipments.controllers');

eqCtrls.factory('eqService', ['$resource', function($resource) {
        return $resource("http://bcunix.test:8080/MYAPP/eq/:Id",
                { Id: "@Id"},
        {
            update: {
                method: "PUT"
            },
            remove: {
                method: "DELETE"
            }
        });
    }]);

})();

結果: GET http://bcunix.test:8080/MYAPP/eq/:Id 400 (不正なリクエスト)

ヘルプ/ヒントをいただければ幸いです。

ありがとう、AdiP

4

1 に答える 1

0

笑、

それでついに私はそれを理解しました。bower install ngResource が bower install angular-resource と等しくないように見えます。間違ったバージョンの ngResource を使用していました。

最新バージョンに更新され、現在動作しています。

私の問題を解決することに興味を持ってくれて、ThomasP1988 に感謝します。

よろしく、 AdiP

于 2014-07-16T11:15:01.423 に答える