为什么我收到此错误:?angular.js:13920错误:[ngRepeat:dupes]错误(本机)

时间:2016-09-23 21:17:11

标签: mysql angularjs codeigniter

enter image description here

我一直想弄清楚我做错了什么,我不断收到此错误消息:

angular.js:13920 Error: [ngRepeat:dupes] http://errors.angularjs.org/1.5.8/ngRepeat/dupes?p0=n%20in%20list_data&p1=string%3A%0A&p2=%0A
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:6:412
at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:302:477
at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:142:77
at m.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:143:181)
at m.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:146:113)
at l (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:97:322)
at J (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:102:34)
at XMLHttpRequest.t.onload (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:103:4)

这是我的观点:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title>Transport View</title>

<link rel="stylesheet" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

</head>
<body>

<div ng-controller="decontroller">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>id</th>
<th>ParticipantName</th>
<th>attendance_mo</th>
<th>attendance_tu</th>
<th>attendance_we</th>
<th>attendance_th</th>
<th>attendance_fr</th>
<th>Lanyard_Status</th>
<th>AssistiveDevices</th>
<th>Lanyard</th>
<th>Wheelchair_Van</th>
<th>Transit_Van</th>
<th>VanComments</th>
<th>Pick Up Time</th>
<th>Drop Off Time</th>
<th>TransportationComments</th>
<th>PCS Monday Hours</th>
<th>PCS Tuesday Hours</th>
<th>PCS Wednesday Hours</th>
<th>PCS Thursday Hours</th>
<th>PCS Friday Hours</th>
<th>stlcid</th>
<th>Physical Address</th>
<th>Disenrolled</th>
<th>Deceased</th>
<th>Comments</th>
<th>Wheelchair Van Comments</th>
<th>Transit Van 240 Comments</th>
<th>Transit Van 360</th>
<th>Transit Van 360 Comments</th>
<th>Subaru Impreza</th>
<th>Subaru Impreza Comments</th>
<th>Address Lat</th>
<th>Address Long</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="n in list_data">
    <td>{{n.id}}</td>
    <td>{{n.ParticipantName}}</td>
    <td>{{n.attendance_mo}}</td>
    <td>{{n.attendance_tu}}</td>
    <td>{{n.attendance_we}}</td>
    <td>{{n.attendance_th}}</td>
    <td>{{n.attendance_fr}}</td>
    <td>{{n.Lanyard_Status}}</td>
    <td>{{n.AssistiveDevices}}</td>
    <td>{{n.Lanyard}}</td>
    <td>{{n.Wheelchair_Van}}</td>
    <td>{{n.Transit_Van}}</td>
    <td>{{n.VanComments}}</td>
    <td>{{n.Pick_Up_Time}}</td>
    <td>{{n.Drop_Off_Time}}</td>
    <td>{{n.TransportationComments}}</td>
    <td>{{n.PCS_Hours_Monday}}</td>
    <td>{{n.PCS_Hours_Tuesday}}</td>
    <td>{{n.PCS_Hours_Wednesday}}</td>
    <td>{{n.PCS_Hours_Thursday}}</td>
    <td>{{n.PCS_Hours_Friday}}</td>
    <td>{{n.stlcid}}</td>
    <td>{{n.physical_address}}</td>
    <td>{{n.disenrolled}}</td>
    <td>{{n.deceased}}</td>
    <td>{{n.comments}}</td>
    <td>{{n.Wheelchair_Van_comments}}</td>
    <td>{{n.Transit_Van_240_comments}}</td>
    <td>{{n.Transit_Van_360}}</td>
    <td>{{n.Transit_Van_360_comments}}</td>
    <td>{{n.Subaru_Impreza}}</td>
    <td>{{n.Subaru_Impreza_comments}}</td>
    <td>{{n.address_lat}}</td>
    <td>{{n.address_long}}</td>
    <td>{{n.phone}}</td>    
</tr>
</tbody>
</table>
</div>
<script type="text/javascript" href="./public/js/angular.js"> </script>
<script type="text/javascript"   src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js">  </script>
<script type="text/javascript">
    var app = angular.module('app',[]);
    app.controller('decontroller', function($scope,$http){
    $scope.list_data=[];
    $http.get("<?php echo site_url("index.php/transport/ajax_load_data")?  >").success(function(result){
        console.log("GOT DATA: "+JSON.stringify(result));
        $scope.list_data=result;
    });
});
</script>
</body>
</html>

这是我的控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Transport extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *      http://example.com/index.php/welcome
     *  - or -
     *      http://example.com/index.php/welcome/index
     *  - or -
     * Since this controller is set as the default controller in
     * config/routes.php, it's displayed at http://example.com/      
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */
    public function list_show_data()
    {

        $this->load->helper('url');
        $this->load->view('transport_view');

    }

    public function ajax_load_data()
    {
        $this->load->helper('url');
        $res = $this->db->get('transportation_properties')->result();
        $data_arr = array();
        $i=0;
        foreach($res as $r)
        {
            $data_arr[$i]['id'] = $r->id;
            $data_arr[$i]['ParticipantName'] = $r->ParticipantName;
            $data_arr[$i]['attendance_mo'] = $r->attendance_mo;
            $data_arr[$i]['attendance_tu'] = $r->attendance_tu;
            $data_arr[$i]['attendance_we'] = $r->attendance_we;
            $data_arr[$i]['attendance_th'] = $r->attendance_th;
            $data_arr[$i]['attendance_fr'] = $r->attendance_fr;
            $data_arr[$i]['Lanyard_Status'] = $r->Lanyard_Status;
            $data_arr[$i]['AssistiveDevices'] = $r->AssistiveDevices;
            $data_arr[$i]['Lanyard'] = $r->Lanyard;
            $data_arr[$i]['Wheelchair_Van'] = $r->Wheelchair_Van;
            $data_arr[$i]['Transit_Van'] = $r->Transit_Van;
            $data_arr[$i]['VanComments:'] = $r->VanComments;
            $data_arr[$i]['Pick_Up_Time'] = $r->Pick_Up_Time;
            $data_arr[$i]['Drop_Off_Time'] = $r->Drop_Off_Time;
            $data_arr[$i]['TransportationComments'] = $r->TransportationComments;
            $data_arr[$i]['PCS_Hours_Monday'] = $r->PCS_Hours_Monday;
            $data_arr[$i]['PCS_Hours_Tuesday'] = $r->PCS_Hours_Tuesday;
            $data_arr[$i]['PCS_Hours_Wednesday'] = $r->PCS_Hours_Wednesday;
            $data_arr[$i]['PCS_Hours_Thursday'] = $r->PCS_Hours_Thursday;
            $data_arr[$i]['PCS_Hours_Friday'] = $r->PCS_Hours_Friday;
            $data_arr[$i]['stlcid'] = $r->stlcid;
            $data_arr[$i]['physical_address'] = $r->physical_address;
            $data_arr[$i]['disenrolled'] = $r->disenrolled;
            $data_arr[$i]['deceased'] = $r->deceased;
            $data_arr[$i]['comments'] = $r->comments;
            $data_arr[$i]['Wheelchair_Van_comments'] = $r->Wheelchair_Van_comments;
            $data_arr[$i]['Transit_Van_240_comments'] = $r->Transit_Van_240_comments;
            $data_arr[$i]['Transit_Van_360'] = $r->Transit_Van_360;
            $data_arr[$i]['Transit_Van_360_comments'] = $r->Transit_Van_360_comments;
            $data_arr[$i]['Subaru_Impreza'] = $r->Subaru_Impreza;
            $data_arr[$i]['Subaru_Impreza_comments'] = $r->Subaru_Impreza_comments;
            $data_arr[$i]['address_lat'] = $r->address_lat;
            $data_arr[$i]['address_long'] = $r->address_long;
            $data_arr[$i]['phone'] = $r->phone;
            $i++;
        }
        trigger_error(print_r($data_arr,TRUE));
        $this->output->set_content_type('application/json');
        echo json_encode($data_arr);
    }
}
  

块引用

我查看了文档,但我仍然无法得到它,请让我知道您认为我可以解决这个问题

1 个答案:

答案 0 :(得分:0)

如果您在回复中使用了重复数据

<tr ng-repeat="n in list_data track by $index">代替<tr ng-repeat="n in list_data">