Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在具有角度的动态数组上排序重复_Angularjs_Sorting_Angularjs Ng Repeat - Fatal编程技术网

Angularjs 在具有角度的动态数组上排序重复

Angularjs 在具有角度的动态数组上排序重复,angularjs,sorting,angularjs-ng-repeat,Angularjs,Sorting,Angularjs Ng Repeat,我有一个通过套接字事件动态填充的数据数组。但是,我无法使用angular的ng repeat对数组进行正确排序: socket.on('twitter:item', function(data){ var item = data; item.time = moment(data.time).valueOf(); item.date = formatTime(data.time); $scope.twitter.push(item); }); <li

我有一个通过套接字事件动态填充的数据数组。但是,我无法使用angular的
ng repeat对数组进行正确排序:

socket.on('twitter:item', function(data){
    var item = data;

    item.time = moment(data.time).valueOf();
    item.date = formatTime(data.time);

    $scope.twitter.push(item);
});


<li ng-repeat="item in twitter | orderBy:time:true">
    <a href>{{item.title}}</a> - {{item.time}} {{item.date}}
</li>
socket.on('twitter:item',函数(数据){
var项目=数据;
item.time=力矩(data.time).valueOf();
item.date=格式时间(data.time);
$scope.twitter.push(项目);
});
  • -{{item.time}{{item.date}
  • html总是在有序列表的底部显示最新的内容…我希望它位于顶部(因此,
    orderBy:time:true
    (或
    false
    ),其中
    time
    是毫秒。这两种方式都不起作用。

    试试
  • orderBy
    接受表达式字符串作为其第一个参数。将对其求值。
    时间
    将被评估为
    未定义
    ,因为它在范围中不存在


    使用单引号将
    'time'
    计算为字符串。

    模型“reverse”的值是多少?我读文档时弄错了。但是它要么是
    真的
    要么是
    假的
    (更新的帖子)试试
  • ,就是这样。回答了,我会接受的。