如何定义不';是否不使用REST GET的查询参数?

如何定义不';是否不使用REST GET的查询参数?,rest,angularjs,Rest,Angularjs,目前,我在Angular中定义了一个资源,如下所示: Users: $resource(APIBASEROUTE +'/users/:_id', {_id: '@_id'}) http://localhost:3000/api/v1/users?id=526eff826a6100fb22000000 http://localhost:3000/api/v1/users/526eff826a6100fb22000000 当我使用此代码呼叫用户时: $scope.user = ayApi.Us

目前,我在Angular中定义了一个资源,如下所示:

Users: $resource(APIBASEROUTE +'/users/:_id', {_id: '@_id'})
http://localhost:3000/api/v1/users?id=526eff826a6100fb22000000
http://localhost:3000/api/v1/users/526eff826a6100fb22000000
当我使用此代码呼叫用户时:

$scope.user = ayApi.Users.get({id:$routeParams.userId});
请求作为查询参数发送,如下所示:

Users: $resource(APIBASEROUTE +'/users/:_id', {_id: '@_id'})
http://localhost:3000/api/v1/users?id=526eff826a6100fb22000000
http://localhost:3000/api/v1/users/526eff826a6100fb22000000
但是,它需要像这样攻击REST服务器:

Users: $resource(APIBASEROUTE +'/users/:_id', {_id: '@_id'})
http://localhost:3000/api/v1/users?id=526eff826a6100fb22000000
http://localhost:3000/api/v1/users/526eff826a6100fb22000000

如何使Angular这样做?

我想问题在于参数名称不一致

在定义中,您有:
{u id:'@\u id'})
,它应该是
{id..

或者在您的通话中,应使用下划线

$scope.user = ayApi.Users.get({_id:$routeParams.userId});

任何其他参数(未在资源定义中映射)被视为查询字符串参数。这就是为什么angular决定将您的
id
附加为查询字符串的一部分。它不是
\u id

Doh!非常感谢您敏锐的眼睛!这让我烦恼了一段时间。很高兴这是一个愚蠢的错误,而不是angular中需要处理的奇怪之处。