asp.net - 如何在 AngularJS 2 中传递查询参数?

标签 asp.net angularjs angular http asp.net-core

我正在使用 ASP.NET Core 和 AngularJS 2。http 查询参数有问题。无论我尝试什么,参数 'quarter' 都不会传递给 Controller ​​。有人知道我在这里错过了什么吗?

getBookingsBySaleUnit() {
    let params: URLSearchParams = new URLSearchParams();
    params.set('quarter', '1');
    let requestOptions = new RequestOptions();
    requestOptions.search = params; 

    this.http.get('/api/method', requestOptions).subscribe(result => {
            this.sales = result.json();
        }
      );
  }

最佳答案

这对我有用:

    let params: URLSearchParams = new URLSearchParams();
    params.set('quarter', 1);
    this.http.get('Result/Delete', { search: params })
       .subscribe([...])

关于asp.net - 如何在 AngularJS 2 中传递查询参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43022423/

相关文章:

asp.net - IIS 和 ASP.Net Web 开发服务器之间的行为差​​异?

angularjs - 有没有办法重置Angular中的$ touched?

node.js - 将同一项目中的 Angular 前端和 NodeJS 后端部署到(Linux)Azure 应用程序服务

javascript - 在 Breeze/Angular 中保留异步查询顺序

Angular:在构造函数中注入(inject)路由器给出错误

css - 对齐卡片内容(图像、文本和按钮)

asp.net - 重定向 w.、ww.、wwww。到 -> www

c# - 递归类型的 ASP.Net 响应为空

ASP.NET IIS错误

angularjs - Sublime Text 中 Angular 模板的特殊颜色标记?