【发布时间】:2016-03-20 21:35:45
【问题描述】:
我在调用从前端到后端的路由时遇到问题。
我在客户端使用 angularjs $state,所以示例 url 是
http://localhost:1234/areas/customer/edit/56e2f6345968f8b812052694
但是,当我在服务器端使用如下 $resouce 查询调用此路由时,它调用了不正确的服务器端路由。
我的工厂包含一个使用 $resource 调用服务器端的方法
getCustomerByID: function(id, callback){
var cb = callback || angular.noop;
return Customer.query(id, function(success){
return cb(success);
}, function(error){
return cb(error);
}).$promise;
}
客户是下面的服务
angular.module('xxx')
.factory('Customer', function ($resource) {
return $resource('/api/customer/:id/:controller', { id: '@_id' })
});
GET的服务器路由如下
router.get('/', controller.index);
router.get('/:id', controller.show);
我需要用 id 打路线,但它似乎打到了第一个
任何想法可能是什么
干杯
【问题讨论】: