为了账号安全,请及时绑定邮箱和手机立即绑定

使用 ng-repeat 表剂量负载数据

使用 ng-repeat 表剂量负载数据

PHP
aluckdog 2023-07-01 13:05:54
我将数据从 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 回答

?
慕雪6442864

TA贡献1812条经验 获得超5个赞

发现问题了

我有 $scope.apply;插入 $scope.$apply();


查看完整回答
反对 回复 2023-07-01
?
慕沐林林

TA贡献2016条经验 获得超9个赞

$scope.carregarClientes()只需在函数声明之后调用即可。您将得到与单击按钮相同的结果。



查看完整回答
反对 回复 2023-07-01
  • 2 回答
  • 0 关注
  • 103 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信