Mohammad  Gholami Mohammad Gholami - 1 month ago 15
PHP Question

How can I use Angular 2 in PHP application?

I am a PHP developer and I started learning Angular2. But I don't know how to use it with PHP.
Is it possible using Angular just as frontend?
What I must to do?
How to use it on shared hosting without Node.js installed?

Answer

Preferably, your site will just download a simple index.html and a file called app.js which contains all of your JS and therefore your Angular app.

PHP will be sitting on a server doing the job of an API, which is answering with JSON/XML to request, you angular app will then use the JSON to build the web interface.

You can have PHP hosted anywhere, and serve your angular app from another place, even thought it's not recommended because of latency

<html>
  <script src="app.js">  
</html>