I've never used a framework at all. I've always had it all on my nail for years. Sunday I started to see about the angle, but I'm bumping into something that should be minimal, but I can not: get data from a php file and put it in my view. Here is what I have already typed. If possible tell me some material to see how php exchanges data with angular.
index.html file
<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
<script src="angular.min.js"></script>
</head>
<body>
<div ng-controller="myController">
<table>
<tr ng-repeat="f in fornecedores">
<td>{{f.id}}</td>
<td>{{f.nome}}</td>
<td>{{f.tipo}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myController", function($scope, $http){
$http.get("buscafornecedores.php").then(function(response){
console.log(response.data);
});
});
</script>
</body>
</html>
Archive search for suppliers.php
<?php
$conn = mysql_connect("localhost", "root", "");
$db = mysql_select_db("myerp");
$sql = mysql_query("select ID,NOME,TIPO from fornecedor limit 5");
$outp = "";
if(mysql_num_rows($sql)>0){
$outp .= "[";
while($rs = mysql_fetch_array($sql)){
$outp .= "{'id':'".$rs["ID"]."',";
$outp .= "'nome':'".$rs["NOME"]."',";
$outp .= "'tipo':'".$rs["TIPO"]."'}";
}
$outp .= "]";
}
echo json_encode($outp);
?>
Thank you in advance.