I am learning Angularjs and i am stuck with getting data from PHP file.
<head>
<script>
var app = angular.module("new",[]);
app.controller("control",function($scope,$http){
$http.get("index.php").then(function(response) {
$scope.database = response.data;
});
});
</script>
</head>
<body ng-app="new">
<div ng-controller="control">
<h1>{{database}}</h1>
</div>
</body>
This the angular script i wrote. My php code is very simple
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
echo "How are you?";
?>
I am not able to get php data onto my html file using angularJS.
I checked the code twice and nothing seem to be missing. I even tried json_encode()
. Did i miss something?