Ng重复未搜索对象

时间:2018-11-23 09:52:14

标签: html angularjs

我的棱形对象使用ng-repeat时遇到问题。我的对象中没有重复的数据。

表格HTML

        <table style="border: black solid 2px;width:400px;height:auto;background-color: wheat;">
      <tr>
        <th>Date</th>
        <th>Panels Completed</th>
      </tr>
      <tr ng-repeat="value in vm.displayData" >
        <td style="text-align:center;border: black solid 2px;">{{value}}</td>
        <td style="text-align:center;border: black solid 2px;" ng-repeat="x in value">{{x}}</td>
      </tr>
    </table>

数据示例:

    KxRkjsAPf0ThgxBOjiE:
    additionalInfo: {components: 8, framingStyle: "SIP 162", nailing: 
"150x150", qty: 1, sheathing: "MGO", …}
    area: "-KsDT3O8DJIGMXmmyXV_"
    dimensions: {area: 0.2, height: 200, length: 1234, weight: 14, 
    width: 162}
    id: "ID"
    project: "-KqdccSuHiz__2UZ0AGX"
    qa: {completed: 1511442566322, completedOperatives: {…}, 
    diagonalHeight: 1250, diagonalLength: 1250, midHeight: 200, …}
    timestamps: {created: 1509089806654, modified: 1511442566322}
    type: "Ext"

Javascript(anglarJs)

    vm.weekStart = weekStart;
vm.weekEnd= weekEnd;
vm.getPanelByDay = getPanelByDay;


getPanelByDay()
        .then(function (data){
          console.log(data);
          vm.dataData = data;
          console.log(vm.dataData); 

        });


function weekEnd(){

  vm.lastDay = plusDays(vm.weekStart("2017-11-21"),5);

  return vm.lastDay;
  function plusDays(value, days) {
    var date = new Date(value);
    date.setDate(date.getDate() + days);
    date.setHours(23, 59, 59,0);
    return date;


    function toIsoDate(value) {
      var date = asDate(value);
      return date.getFullYear()+"-" + ("0" + (date.getMonth()+1)).slice(-2) + "-"+ ("0" + date.getDate()).slice(-2);

      function asDate(value) {
          return angular.isDate(value) ? value : new Date(value);
      }  
    }        

  }
}

  function weekStart(value) {
    if (angular.isDefined(value)) {
      var date = new Date(value);
    } else {
      var date = new Date();
    }
    date.setDate(date.getDate() - dayOfWeek(date));
    date.setHours(0,0,0,0);
    return date;

    function dayOfWeek(value) {
      var date = asDate(value);
      return (date.getDay() + 6) % 7;

      function asDate(value) {
        return angular.isDate(value) ? value : new Date(value);
      }          
    }

  function asDate(value) {
    return angular.isDate(value) ? value : new Date(value);
  }
  function toIsoDate(value) {
    var date = asDate(value);
    return date.getFullYear()+"-" + ("0" + (date.getMonth()+1)).slice(-2) + "-"+ ("0" + date.getDate()).slice(-2);

  function asDate(value) {
    return angular.isDate(value) ? value : new Date(value);
  }
  }

  }

function getPanelByDay(){
  var todayDate = new Date("2017-11-21");
  var startDay =  new Date(vm.weekStart(todayDate)).getTime();
  var endDay = new Date(vm.weekEnd(todayDate)).getTime();
  var weeklyPanels = {};

  return realDatabaseRef.child("panels").orderByChild("qa/completed").startAt(startDay).endAt(endDay).once("value").then(function(snapshot){
    for(snap in snapshot){
      var data = snapshot.val();

      angular.forEach(data,function(info,key){
        var PanelCompletedDate = toIsoDate(info.qa.completed);

         if(angular.isUndefined(weeklyPanels[PanelCompletedDate])){
           weeklyPanels[PanelCompletedDate] = {};

         }
         if(angular.isUndefined(weeklyPanels[PanelCompletedDate][key])){
           weeklyPanels[PanelCompletedDate][key] = {};

         }
         weeklyPanels[PanelCompletedDate][key] = info;

       });
    }
    return weeklyPanels;
  })
  .then(function (pa){
    return pa;
  });



  function toIsoDate(value) {
    var date = asDate(value);
    return date.getFullYear() + "-" + ("0" + (date.getMonth() + 1)).slice(-2) + "-" + ("0" + date.getDate()).slice(-2);

    function asDate(value) {
      return angular.isDate(value) ? value : new Date(value);
    }
  }         

}

JS有点混乱,我从当前的工作系统中删除了大多数功能,然后将它们放到了单独的网页中。我能够看到我要填充数据和在视图中使用充满数据,只是没有被使用或在某处被删除,但我仍然被卡住

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

也许您应该使用ng-repeat-startng-repeat-end进行嵌套重复。