POST to a PHP file from Angular using jquery

one text

Solution:

Angular's localhost environment (from ng serve) is a basic HTTP server for testing your Angular app. It is not meant to run files like PHP, and it is not the server that is used when you deploy to a production environment.

If you want to test your Angular app with PHP, you will need to build your app ng build then use a PHP test server (ex: MAMP) that points to the build folder.

I would recommend reading up on resources other developers have posted about how to build an Angular app with a PHP back-end. This may give you pointers on how to structure your repo.

Lastly, I would strongly recommend not to use jQuery inside an Angular project. Angular is a full front-end framework that comes with robust tools. Even if you have more familiarity with jQuery, it would be more beneficial to invest the time in learning how to use Angular's toolset.

Source