javascript - How to setup php in my Angular project? -


i trying setup angular project has php backend. project setup followed:

project    -app      -api        -test.php      -scripts        -app.js        -test.controller.js      -css      -images      ...others 

in test.controller.js

angular.module('myapp')   .controller('mainctrl', function ($http) {   $http.get('api/test.php').then(function(res) {      console.log(res)  })  ...more }); 

inside test.php

<?php     ..php codes     ..calculate stuff.     ..generate $result  echo json_encode($result); 

for reason, when load page, can see request entire test.php code instead of data need.

for example:
return i've got

"<?php↵header("content-type: application/json", true);...more... 

i have virtual host setup , not sure went wrong. me it?


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -