Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

angular - Property does not exist on type 'never' - on ngFor variable

When I'm trying to get responses from API, I use an ngFor for dynamically sorting my view. Here's the line of code:

  <agm-marker *ngFor="let httpResponses of response" [latitude]= "httpResponses.lat" [longitude]="httpResponses.lng"
        [agmFitBounds]="true">

To be more clear:

... *ngFor="let httpResponses of response" [latitude]= "httpResponses.lat" [longitude]="httpResponses.lng" ...

and it gives automatically the type of httpResponses as never. And because of that gives these errors below:

error TS2339: Property 'lng' does not exist on type 'never'.

error TS2339: Property 'lat' does not exist on type 'never'.

Can I declare any Typescript type on httpResponse in the Html file? The project works fine, I get the lat and lng values from httpResponses and display it, but however I constantly get these errors, I tried to declare type on httpResponses in component.ts file, it didn't change anything.

Thanks for any advice.

question from:https://stackoverflow.com/questions/65918642/property-does-not-exist-on-type-never-on-ngfor-variable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...