This question is similar to another one about how to get the current location in Typescript and pass it to a backend, which was answered by libertyernie. However, this time I need help with integrating the current location into an Angular Material 2 table for displaying restaurant data from a Spring Boot backend. The tutorial on GitHub specifies that the data source must be observable to enable features like sorting and filtering. Unfortunately, I am struggling to make it work...
The scenario is as follows: I want to retrieve the user's current location (e.g., lat=123
and lon=123
) and then pass these parameters to my backend API endpoint at
http://localhost:8080/api/search/location?lat=123&lon=123
. This will return a list of restaurants that I need to convert to an Observable format so that the connect()
function in ExampleDataSource
can function properly.
I have attempted the code below, but the datasource does not receive any data back:
(insert code here)
You can find the full code on Github: https://github.com/zhengye1/Eatr/tree/dev