Reputation: 1622
I am using ASP.NET Core and AngularJS 2. There is a problem with http query parameter. No matter what I try, parameter 'quarter'
is not passed to controller. Anyone have idea what ma I missing here ?
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();
}
);
}
Upvotes: 2
Views: 143
Reputation: 1
You missed to pass the parameter. Try the code below which includes parameter in the URL.
getBookingsBySaleUnit() {
let params: URLSearchParams = new URLSearchParams();
params.append('quarter', '1');
let requestOptions = new RequestOptions();
requestOptions.headers.set('Content-Type', 'application/x-www-form-urlencoded');
this.http.get('/api/method?'+params.toString(), requestOptions).subscribe(result => {
this.sales = result.json();
});
}
Upvotes: 0
Reputation: 1415
This works for me:
let params: URLSearchParams = new URLSearchParams();
params.set('quarter', 1);
this.http.get('Result/Delete', { search: params })
.subscribe([...])
Upvotes: 1