角度跟踪by和orderBy [英] angular track by and orderBy

查看:86
本文介绍了角度跟踪by和orderBy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开始使用Angular并进行演示. 在模型中,事件项包括一个称为starts_at的开始时间和一个标题.

我有一个使用ng-repeat ="event in $ index的事件跟踪中的标记",并尝试添加"| orderBy:event.starts_at",直到我删除了跟踪,它似乎都没有以任何方式影响排序部分.

track是否禁用按角度排序的任何选项?

解决方案

根据文档: https://docs .angularjs.org/api/ng/directive/ngRepeat 过滤器表达式(我怀疑是顺序)出现在跟踪表达式之前.

示例:

item in items | filter:searchText track by item.id

Starting to use Angular and playing with a demo. In the model, the event item includes a start time called starts_at and a title.

I had a tag using ng-repeat="event in events track by $index" and tried adding in "|orderBy: event.starts_at" It didn't seem to influence the sorting in any way until I removed the track section.

Does track disables any option for sorting in angular ?

解决方案

According to docs: https://docs.angularjs.org/api/ng/directive/ngRepeat filter expressions (and I suspect, order) come before tracking expressions.

Example:

item in items | filter:searchText track by item.id

这篇关于角度跟踪by和orderBy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆