如何在 ng-repeat 中使用过滤器?
How to use a filter in ng-repeat?
<table class="table table-bordered table-striped table-condensed">
<thead>
<th>ID</th>
<th>Shop ID</th>
<th>Total Price</th>
<th>Date</th>
<th>Status</th>
</thead>
<tr ng-repeat="order_item in orderitemList | orderBy: 'id'">
<td ng-bind="order_item.id"></td>
<td ng-bind="order_item.shop_id"></td>
<td ng-bind="order_item.total_price"></td>
<td>{{order_item.date | date:'dd.MM.yyyy'}}</td>
<td ng-bind="order_item.status"></td>
</tr>
</table>
我尝试使用 |my filter 功能但它没有用,所以我认为还有一些其他方法可以将订单项目状态替换为其他含义。在数据库状态数据类型是“bigint”,我想用数据类型字符串来显示含义!此致,提前致谢!
您需要创建自定义管道 (how-to),然后在 transform()
方法中使用 bigInt`(也许是字符串开关?) 和 return 值
<table class="table table-bordered table-striped table-condensed">
<thead>
<th>ID</th>
<th>Shop ID</th>
<th>Total Price</th>
<th>Date</th>
<th>Status</th>
</thead>
<tr ng-repeat="order_item in orderitemList | orderBy: 'id'">
<td ng-bind="order_item.id"></td>
<td ng-bind="order_item.shop_id"></td>
<td ng-bind="order_item.total_price"></td>
<td>{{order_item.date | date:'dd.MM.yyyy'}}</td>
<td ng-bind="order_item.status"></td>
</tr>
</table>
我尝试使用 |my filter 功能但它没有用,所以我认为还有一些其他方法可以将订单项目状态替换为其他含义。在数据库状态数据类型是“bigint”,我想用数据类型字符串来显示含义!此致,提前致谢!
您需要创建自定义管道 (how-to),然后在 transform()
方法中使用 bigInt`(也许是字符串开关?) 和 return 值