obar
obar

Reputation: 105

How to convert () => number to number in Angular

I have issue with converting. I getting error like this:

Type '() => number' is not assignable to type 'number'.

In this part of code:

...
for (let g of parcelData.geom){
      const point = [];
      let lat : number;
      lat = g.lat; // error there
...

Somebody can tell me how i can convert this to classic number?

Upvotes: 0

Views: 715

Answers (2)

Arash
Arash

Reputation: 1826

g.lat() is a function and you should assign it like below.

lat = g.lat()

Upvotes: 3

Chanaka Weerasinghe
Chanaka Weerasinghe

Reputation: 5742

Note

first of all check data type of parcelData.geom

console.log(typeof parcelData.geom);

then change below according to that

let lat : number;<----then change this
  lat = g.lat;  

Upvotes: 0

Related Questions