Amal
Amal

Reputation: 305

Angular 2 - Using let giving error

While trying to use 'let' in angular 2 I am getting this error : Unexpected Token : A constructor, method, accessor or property was expected.

 let options = new RequestOptions({
      search: new URLSearchParams('XXX') 
  });

Upvotes: 2

Views: 1107

Answers (1)

FAISAL
FAISAL

Reputation: 34673

You cannot use let when declaring a class property. You can only use let in a block scope e.g. inside a method. Change your code to this:

options = new RequestOptions({
      search: new URLSearchParams('XXX') 
  });

you can use public or private modifiers before options if you want. If you dont specify any modifier, then by default it is public.

Upvotes: 2

Related Questions