douyi3676 2016-05-30 21:53
浏览 35
已采纳

没有显示任何代替AngularJS表达式的内容

I am trying to fetch data from mysql using php and trying to pass the data in json format to angularjs so that I can display data in table.

HTML code is:

<body ng-app="myModule">
<div class="row">
        <div class="col-lg-12 text-center">
             <div ng-controller="myController">
              <table class="table">
                <thead>
                    <tr>
                        <th>email</th>
                        <th>id</th>
                        <th>name</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="employee in employees"></tr>
                    <td>{{employee.username}}</td>
                    <td>{{employee.id}}</td>
                    <td>{{employee.name}}</td>
                </tbody>
              </table>
             </div>

        </div>
    </div>
    <!-- /.row -->

</div> 

AngularJS code is:

var app = angular
        .module("myModule", [])
        .controller("myController", function ($scope,$http) {
            $http.post('http://enrolin.in/test/login.php')
                 .then(function(response){
                    $scope.employees=response.data;
                 }); });

Working php link that outputs json is : http://enrolin.in/test/login.php Working link of table is http://enrolin.in/test/

But when I try to load the html. It does not load any data from the database.

I tried to view it in console, looks like ng-repeat is repeated 6 times that is exactly the number of rows in database that means data is imported but is not being displayed somehow

I tried to view it in console, looks like ng-repeat is repeated 6 times that is exactly the number of rows in database that means data is imported but is not being displayed somehow

  • 写回答

2条回答 默认 最新

  • doushizhou4477 2016-05-30 22:52
    关注

    The problem seems to be in your HTML.

    <tr ng-repeat="employee in employees"></tr>
        <td>{{employee.username}}</td>
        <td>{{employee.id}}</td>
        <td>{{employee.name}}</td>
    

    The <td> are outside the <tr>, so {{ employee }} does not exist in the <td>.

    This should work :

    <tr ng-repeat="employee in employees">
        <td>{{employee.username}}</td>
        <td>{{employee.id}}</td>
        <td>{{employee.name}}</td>
    </tr>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器