I am calling a method in angular but I am getting this error :
TypeError: this.saveCoordinates is not a function
Could you please help me to understand ? This is the code :
export class AppComponent {
constructor( public http: HttpClient) {
}
public saveCoordinates(){
///post request here
this.http.post<any>('http://localhost:8080/api/tutorials', {
"title":lat,
"description":ling
}).subscribe(data => {
console.log(data)
})
///post request here
}
ngOnInit() {
map.on('click', function(e) {
this.saveCoordinates()
});
}
}