gpt4 book ai didi

javascript - 我试图打印数组索引,但是我们如何在 angularjs 中以相反的顺序进行打印

转载 作者:行者123 更新时间:2023-11-27 22:42:08 25 4
gpt4 key购买 nike

<tr ng-repeat="qualityalert in qualityalerts" current="$parent.start;$parent.start=$parent.start+(qualityalerts.length);">
<td class="v-middle">{{current + $index}}</td>
</tr>

注意:这是我所指的,但我希望在 Angular js 中以相反的顺序排列数组索引。

最佳答案

<div ng-app="myapp" ng-controller="AppController">
<table class="friends">
<tr>
<th>Order</th><th>Name<th><th>Phone Number</th><th>Age</th>
</tr>
<tr ng-repeat="(k,friend) in friends| orderBy:'-' ">
<td>{{friends.length - $index}}</td>
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<td>{{friend.age}}</td>
</tr>
</table>
</div>


app=angular.module('myapp', [])
app.controller('AppController', ['$scope', function($scope) {
$scope.friends = [
{name: 'John', phone: '555-1212', age: 10},
{name: 'Mary', phone: '555-9876', age: 19},
{name: 'Mike', phone: '555-4321', age: 21},
{name: 'Adam', phone: '555-5678', age: 35},
{name: 'Julie', phone: '555-8765', age: 29}
];
}]);

Demo Link

检查一下。我认为这会对您有所帮助

关于javascript - 我试图打印数组索引,但是我们如何在 angularjs 中以相反的顺序进行打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38670434/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com