How to integrate Angular application with MySQL database?
P粉613735289
P粉613735289 2023-07-20 21:47:01
0
1
523

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.

P粉613735289
P粉613735289

reply all(1)
P粉729518806

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!