Reputation: 3162
I am a newbie to Angular. In my Angular 2 web application I am trying following to call backend service with URL parameters.
import {Http, Response} from 'angular2/http'
import {Injectable} from 'angular2/core'
@Injectable()
export class DataService {
http: Http;
constructor(http: Http) {
console.log('Creating DataService');
this.http = http;
}
getList(param1) {
let params: URLSearchParams = new URLSearchParams();
params.set('param1', param1);
return this.http.get('http://localhost:8080/test/getList', { search: params }).map((res: Response) => res.json());
}
}
This gives a compile error in the Visual Studio Code console.
Cannot find name 'URLSearchParams'
Does anyone have an idea what's wrong with my code?
Upvotes: 0
Views: 501
Reputation: 3162
Issue solved by adding following import statement.
import {Http, Response, URLSearchParams} from 'angular2/http'
Upvotes: 3