问题
Creating an angular2 app using angular2cli the php files are not being compiled correctly wondering if the server that comes with angular cli understand php. If not are there any suggestions for angular2cli to understand php
回答1:
Angular-cli runs a server called 'livereload server' (https://github.com/napcs/node-livereload).
When you run "ng serve" you would probably be seeing a message like:
"Livereload server on http: //localhost:49152
Serving on http: //localhost:4200/"
Livereload server runs on top of NodeJS which is used to execute javascript. To execute php files, you will have to run some other server concurrently, eg. Apache. After running the apache server, you will have to load the URL specified in the apache configuration file instead of the one specified by Livereload. Your php files should now get executed properly, the drawback being live reload of your webpage will not be working.
This is the solution I am using and it works perfectly.
来源:https://stackoverflow.com/questions/38465263/executing-php-files-in-a-angular2cli-app