My interface :
export interface MapMarker{
longitude: number,
latitude: number,
popupText: string
}
My component
mapMarker: MapMarker;
ngOnInit() {
this.mapMarker.latitude = location.coords.latitude;
this.mapMarker.longitude = location.coords.longitude;
this.mapMarker.popupText = "Your current Location"
}
this tells me that can't set latitude of undefined. I know why is that. It's because mapMarker has a type MapMarker but is undefined, because it's undefined by default. What should I do? if I try mapMarker: MapMarker = null; still wrong.
I also tried mapMarker: MapMarker = {}; which gives me following error = Type '{}' is missing the following properties from type 'MapMarker': longitude, latitude, popupText
I need the solution, but i don't want to use 'any' type.