I'm writing my first Angular application, but don't know how to integrate it with a MySQL database.
This is a method in the controller:
@GetMapping(value = "/{employeeId}") public Employee findEmployeeById(@PathVariable Long employeeId) { return employeeService.getById(employeeId); }
A fragment of app.component.ts:
constructor(private http: HttpClient) { this.http.get<Employee>("http://localhost:8080/employees/{employeeId}").subscribe(result => { this.employee = result; console.log(this.employee); }); }
Angular and Spring applications both start, but only show a blank page on localhost:4200. The @CrossOrigin(origins = "http://localhost:4200") annotation has been added.
The best way is to create a REST API and send requests to the backend via POST request or GET request. You should run Node.js on another port and request your data.