我有以下问题: 我正在使用ui-router在页面上显示ng-grid。但是$ resource在发送到服务器时没有更改url中的参数(例如http://bcunix.test:8080/MYAPP/eq/:Id)。 :Id没有更改,我从服务器收到Bad请求,因为我发送:Id。
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"
}
});
}]);
})();
结果: 获取http://bcunix.test:8080/MYAPP/eq/:Id 400(错误请求)
任何帮助/提示都将不胜感激。
谢谢, ADIP
答案 0 :(得分:0)
洛尔,
所以我终于明白了。 看起来像bower安装ngResource不等于bower安装角度资源。 我使用的是错误版本的ngResource。
已更新至最新版本,现在正在使用。
感谢ThomasP1988对解决我的问题感兴趣。
祝你好运, ADIP