次の問題があります: ページに 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