angularjs - $httpProvider请求拦截器-获取参数

标签 angularjs

我需要向我的一些 $http 调用添加一个查询字符串。 现在 $httpProvider.defaults.transformRequest 似乎接收到 2 个对象: data 和 headersGetter,都不允许我直接更改 url 或添加 get 变量。

有什么想法吗?

最佳答案

你需要一个拦截器。来自 $http 上的 Angular 文档:

There are two kinds of interceptors (and two kinds of rejection interceptors):

request: interceptors get called with http config object. The function is free to modify the config or create a new one. The function needs to return the config directly or as a promise.

关于angularjs - $httpProvider请求拦截器-获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17972982/

相关文章:

javascript - Angular - 指令中的引用范围变量没有 $scope?

javascript - 在 Angular 中实现取消编辑

javascript - 类似的 $http 请求首先陷入挂起状态,然后 NodeJS 服务器失败

javascript - AngularJS 无法看到必填字段

javascript - 显示表格根据动态选项的选择变化进行显示

javascript - AngularFire:返回 $value

android - CacheFactory 在我的浏览器中工作但在我的 apk 中不工作

javascript - 从 Angular Controller 控制 SoundCloud js sdk

AngularJS ng-include

javascript - D3图表 Angular Directive(指令)不呈现