Guru
Guru

Reputation: 9

Error : property does not exist on type

I am a newbie in coding world and learning angular 4. In my application, I have 3 classes MyGlobalObject.ts, globalservice.service.ts and history.ts.

I am trying to fetch the data from a JSON file (API) having the values in history.ts, but in globalservice class, I am getting an error saying property startdateandtime does not exist on type History[].

But the property do exist in the history.ts as shown in the above images having code.

myglobalobject.ts:

CodeScreenshot#1

CodeScreenshot#2


History.ts:

CodeScreenshot#3


globalservice.service.ts:

CodeScreenshot#4

Upvotes: 0

Views: 1621

Answers (1)

Harshal Yeole
Harshal Yeole

Reputation: 4983

The error means the type you have assigned to the variables is different than the data you are trying to put into it.

In your file, either declare type as any. or know the type of data you are going to put into the variable

example:

slno:  any;

Upvotes: 1

Related Questions