0

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?

1 Answer 1

3

Issue solved by adding following import statement.

import {Http, Response, URLSearchParams} from 'angular2/http'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.