2016-10-16 45 views
0

我想顯示一個來自mongodb的結果表,但我只是想收集一些結構並同時學習,所以我現在只是在控制器內獲得了一些虛擬數據模態視圖中的ng-repeat不起作用

app.controller('modal-controller', function($scope) { 
$scope.fakeResults = [ 
    { 
     "id": "1", 
     "location": "3", 
     "value": "27.5" 
    }, { 
     "id": "2", 
     "location": "3", 
     "value": "27.0" 
    }, { 
     "id": "3", 
     "location": "3", 
     "value": "27.2" 
    }, { 
     "id": "4", 
     "location": "3", 
     "value": "27.9" 
    }, { 
     "id": "5", 
     "location": "3", 
     "value": "28.5" 
    } 
]; 
}); 

爲模態部分即時試圖查看結果的HTML下面

<div ng-controller="modal-controller" class="portfolio-modal modal fade" id="portfolioModal1" tabindex="-1" role="dialog" aria-hidden="true"> 
    <div class="modal-content"> 
     <div class="close-modal" data-dismiss="modal"> 
      <div class="lr"> 
       <div class="rl"> 
       </div> 
      </div> 
     </div> 
     <div class="container"> 
      <div class="row"> 
       <div class="col-lg-8 col-lg-offset-2"> 
        <div class="modal-body"> 
         <h2>Temperature Table</h2> 
         <hr class="star-primary"> 
         <p>TEST TEXT {{ fakeResults }}</p> 
         <tbody> 
          <tr ng-repeat="result in fakeResults"> 
           <td>{{$index + 1}}</td> 
           <td>{{result.id}}</td> 
           <td>{{result.location}}</td> 
           <td>{{result.value}}</td> 
          </tr> 
         </tbody> 
         <img src="img/portfolio/cabin.png" class="img-responsive img-centered" alt=""> 
         <p>This page will be used to display simple table of temperature results</p> 
         <ul class="list-inline item-details"> 
          <li>Hardware: 
           <strong>Tinkerforge equipment linked</strong> 
          </li> 
          <li>Software: 
           <strong>Github Link</strong> 
          </li> 
          <li>Difficulty: 
           <strong>1</strong> 
          </li> 
         </ul> 
         <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> Close</button> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 

的結果是觀察數據的整個樣品後可見,但不與NG-重複。不太清楚爲什麼這是,但希望將其縮小到ng-repeat的範圍內。

謝謝

回答

0

你忘記表標籤在你的tbody

    <table> 
         <tbody> 
          <tr ng-repeat="result in fakeResults"> 
           <td>{{$index + 1}}</td> 
           <td>{{result.id}}</td> 
           <td>{{result.location}}</td> 
           <td>{{result.value}}</td> 
          </tr> 
         </tbody> 
        </table>