PHP + Angular, help me with a simple example


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">
<meta charset="utf-8">
<title>Documento sem título</title>
<script src="angular.min.js"></script>


<div ng-controller="myController">
        <tr ng-repeat="f in fornecedores">

    var app = angular.module("myApp", []);

    app.controller("myController", function($scope, $http){


Archive search for suppliers.php


$conn = mysql_connect("localhost", "root", "");
$db = mysql_select_db("myerp");

$sql = mysql_query("select ID,NOME,TIPO from fornecedor limit 5");

$outp = "";

    $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.

asked by anonymous 29.09.2017 / 00:46

1 answer


Look, without wanting to find out something ... I put a border="1" in the table, and I verified that the table is being mounted with the cells, but without the data. Empty cells.

Dai moved to other tables in the bank and even hit one that showed an ID field, and another that showed the name of the products. But it just shows tbm with track by $ index, otherwise it says it has repeated data.

Now: Is it a problem in BD Mysql? Any light?

30.09.2017 / 18:20