【发布时间】:2019-08-29 21:44:27
【问题描述】:
我想将我的数据绑定到下面的 HTML 表格:
<table id="tableAccounts">
<thead>
<tr>
<th>No.</th>
<th>Status</th>
<th>Code</th>
<th>Name</th>
<th>Deposit / Credit Limit</th>
<th>Date Joined</th>
<th>Total Course</th>
<th>UPV Cost</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="account in accounts">
<td>{{ $index + 1 }}</td>
<td>{{ account.AccStatus }}</td>
<td>{{ account.id }}</td>
<td>{{ account.AccName }}</td>
<td>{{ account.Deposit }}</td>
<td>{{ account.DateJoined }}</td>
<td>{{ account.TotalCourse }}</td>
<td>{{ account.UpvCost }}</td>
</tr>
</tbody>
</table>
所以我的 AngularJS 控制器中有以下代码:
var db = firebase.firestore();
db.collection("Accounts").get().then((querySnapshot) => {
if (!querySnapshot.empty) {
$scope.accounts = querySnapshot.docs.map(doc => doc.data());
$scope.$apply();
}
});
但上面的代码在执行映射时不包括doc.data() 中的doc.id。如何在这种情况下包含 doc.id 以便它可以绑定到我的 HTML 表的 Code 列?
【问题讨论】:
标签: angularjs google-cloud-firestore