我将数据从 php 加载到 Angular js 中的变量,但表未加载数据并保持为空
<script>
var app = angular.module('clientesApp', []);
app.controller('clientesController', function ($scope,$interval) {
$scope.clientes =[];
$scope.error = [];
$scope.alertMsg=false;
$scope.carregarClientes = function () {
$.getJSON(
"/abcaia/getclientes.php", {},
function (jsonData) {
$scope.clientes = jsonData;
console.log($scope.clientes);
$scope.applay;
});
};
});
</script>
我添加了一个按钮,该按钮调用请求数据的功能,然后加载数据,但我希望它在页面加载时加载
<div ng-init="carregarClientes()">
<button id="btnEnviaComent" class="btn btn-success btn-x" ng-click="carregarClientes()">
Enviar
</button>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>id</th>
<th>info</th>
</tr>
</thead>
<tbody ng-repeat = "c in clientes" >
<td>{{c.idCliente}}</td>
<td>{{c.info}}</td>
</tbody>
</table>
</div>
慕雪6442864
慕沐林林