模态视图中的 ng-repeat 不起作用
ng-repeat within modal view not working
我正在尝试显示来自 mongodb 的 table 结果,但我只是想收集一些结构并同时学习,所以我现在只得到了一些虚拟数据控制器
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-repeat 则看不到。不太确定这是为什么,但我希望将其缩小到 ng-repeat 周围的范围。
谢谢
您忘记了 table 标签在您的身体周围
<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>
我正在尝试显示来自 mongodb 的 table 结果,但我只是想收集一些结构并同时学习,所以我现在只得到了一些虚拟数据控制器
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-repeat 则看不到。不太确定这是为什么,但我希望将其缩小到 ng-repeat 周围的范围。
谢谢
您忘记了 table 标签在您的身体周围
<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>