###Exemplo minimo com busca feita no banco de dados
Tabelas
Html
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
form.label {
width: 150px;
}
</style>
<!--<link href="css/style.css" rel="stylesheet">-->
</head>
<body ng-controller="indexCtrl">
<div>
<select name="s1" ng-options="item1.idestabelecimento as item1.nome for item1 in dropItens1" ng-model="dropSelected1" ng-change="selectChange()">
</select>
<select name="s2" ng-options="item2.idunidade as item2.nome for item2 in dropItens2" ng-model="dropSelected2">
</select>
</div>
<script src="js/angular.min.js"></script>
<script>
var app = angular.module('app', []);
app.controller("indexCtrl", ["$scope", "$http", function($scope, $http)
{
$scope.dropItens1 = [];
$scope.dropSelected1 = 0;
$scope.dropItens2 = [];
$scope.dropSelected2 = 0;
$scope.selectChange = function()
{
$scope.dropItens2 = [];
$scope.dropSelected2 = 0;
$http.get('rest.php?select=2&&id=' + $scope.dropSelected1)
.then(function($result){
$scope.dropItens2 = $result.data;
$scope.dropSelected2 = $result.data[0].idunidade;
});
}
$scope.init = function()
{
$http.get('rest.php?select=1')
.then(function($result){
$scope.dropItens1 = $result.data;
$scope.dropSelected1 = $result.data[0].idestabelecimento;
$scope.selectChange();
});
}
$scope.init();
}]);
</script>
</body>
</html>
PHP
<?php
function getConexao()
{
$dns = 'mysql:host=localhost;dbname=testdb';
return new pdo($dns, 'root', 'senha');
}
$pdo = getConexao();
function getEstabeleciomento($pdo)
{
$result = $pdo->query('SELECT * FROM `estabelecimento`', PDO::FETCH_ASSOC);
$result->execute();
return json_encode($result->fetchAll());
}
function getUnidade($pdo, $id = 0)
{
$result = $pdo->prepare('SELECT * FROM `unidade` where idestabelecimento=?');
$result->bindValue(1, $id, PDO::PARAM_INT);
$result->execute();
return json_encode($result->fetchAll());
}
$select = isset($_GET['select'])
? (int)$_GET['select']
: 1;
if ($select === 1) echo getEstabeleciomento($pdo);
if ($select === 2)
{
$id = $_GET['id'];
echo getUnidade($pdo, (int)$id);
}