gpt4 book ai didi

javascript - ng-repeat order仅更改一次

转载 作者:行者123 更新时间:2023-12-02 16:46:15 25 4
gpt4 key购买 nike

我正在尝试使用 Angular 创建一个表,其中的 header 可以设置顺序,到目前为止它可以工作,但它只设置顺序一次。

我使用了console.log并且变量正在改变。

表格

<table class="table table-striped table-bordered">
<thead>
<tr>
<th ng-click="setOrder('iss.issueID')"> ID</th>
<th ng-click="setOrder('iss.issueTitle')" >Issue</th>
<th ng-click="setOrder('iss.zone')">Zone</th>
<th ng-click="setOrder('iss.type')">Type</th>
<th ng-click="setOrder('iss.time')">Time</th>
<th ng-click="setOrder('iss.userID')">User ID</th>
<th ng-click="setOrder('iss.user')">User</th>
</tr>
</thead>
<tbody>
<tr ng-repeat= "iss in issues | filter:name | orderBy:order">
<td>{{ iss.issueID }}</td>
<td>{{ iss.issueTitle }}</td>
<td>{{ iss.zone }}</td>
<td>{{ iss.type }}</td>
<td>{{iss.time * 1000 | date:'yyyy-MM-dd HH:mm:ss '}}</td>
<td>{{ iss.userID }}</td>
<td>{{ iss.user }}</td>
</tr>
</tbody>
</table>

功能

$scope.issues = [

<? php

$result = mysqli_query($con, $qr);
while ($row = mysqli_fetch_array($result)) {

echo "{issueID: '".$row['issueID']."',
user: '".$row['firstName'].' '.$row['lastName']."',
userID: '".$row['userID']."',
issueTitle: '".$row['issue']."',
issueDesc: '".$row['issueDesc']."',
time: '".$row['timeReceived']."',
machine: '".$row['machineID'].' '.$row['manufacturer'].' '.$row['machineType']."',
zone: '".$row['zoneID'].' '.$row['Location'].' '.$row['Name']."',
type: '".$row['type']."',
technician: '".$row['techID']." ".$row['tfirstName']." ".$row['tlastName']."'";
echo "},";
}

?>
];

$scope.setOrder = function (order) {
$scope.order = order;
console.log($scope.order = order);
};
});

最佳答案

您向 setOrder 函数传递了错误的值。

您应该删除 iss. 部分。您只需要对象的实际键名称。

<tr>
<th ng-click="setOrder('issueID')"> ID</th>
<th ng-click="setOrder('issueTitle')" >Issue</th>
<th ng-click="setOrder('zone')">Zone</th>
<th ng-click="setOrder('type')">Type</th>
<th ng-click="setOrder('time')">Time</th>
<th ng-click="setOrder('userID')">User ID</th>
<th ng-click="setOrder('user')">User</th>
</tr>

演示地址:http://plnkr.co/edit/Afh8ha5F7zBgGa2CaO4o?p=preview

关于javascript - ng-repeat order仅更改一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27093896/

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