我將數據從 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>
- 2 回答
- 0 關注
- 173 瀏覽
添加回答
舉報
0/150
提交
取消