将参数传递给$resource(使用 @)
Passing parameters to $resource (using @)
在我的控制器中:
UserResource.find({ userId: userId }, function (records) {
$scope.user= records;
});
在我的资源中:
angular.module("main_k").
factory("main_k.service.resource.Order", ["$resource", function ($resource) {
return $resource("../rest/user/:action?:identification", {
action: "@userId",
identification: "identification51854"
}, { find: { method: "GET"}
});
}]);
问题是 userId 被附加到 url 而不是被填充到操作中。 标识正确填写。为了传递 userId 值,我做错了什么?
这
有点奇怪。当你做GET请求时,你需要设置原始变量名:action
而不是userId
UserResource.find({
action: userId
}, function (records) {
$scope.user = records;
});
相关文章:
- 使用$resource发送音频数据(base64)
- AngularJS:如何使用$resource请求发送身份验证令牌
- 使用$resource时,量角器等待与页面同步超时
- 使用$resource时未保存数据
- 从使用 $resource 的服务返回新对象
- 使用$resource从angular js调用rest api
- angular ui指令未绑定到使用$resource加载的数据
- 如何使用$resource在angular js中使用$timeout
- 如何用REST定义AngularJs的服务(使用$resource)和其他方法
- 如何使用$resource解析
- 使用$resource service访问REST API
- 使用$resource添加新项目
- 使用$resource并在多个控制器之间共享结果的最佳实践是什么?
- 在自定义解析器中使用$resource返回值
- Angularjs使用$resource获取响应的值
- 如何在AngularJS中使用$resource查询所有的东西
- 如何在AngularJS中使用$resource在URL查询字符串中传递HTML表单字段中的数据
- 如何让AngularJS使用$resource来返回multi
- 使用$resource时没有new操作符的问题
- 如何在angularjs中使用$resource取消承诺