我正在显示城市及其国家列表。国家每次更改时,我都想显示国家一次。数据已经排序,以便所有国家都很好地组合在一起。如何在ng-repeat中检测Country的变化,如下所示:
Cursor res = myDb.getAllData();
if(res!=null&&res.getCount()>0){
while (res.moveToNext()){
weight = res.getString(res.getColumnIndex("WEIGHT"));
height = res.getString(res.getColumnIndex("HEIGHT"));
Log.i("Weight", weight);
Log.i("Height", height);
答案 0 :(得分:0)
尝试以下方法:
<div ng-repeat="row in data.cities track by data.cities">
{{row.country}}
{{row.city}}
</div>
答案 1 :(得分:0)
这对我有用:
<div ng-repeat="(key, value) in data.cities| groupBy: 'country'">
{{key}}
<div ng-repeat="row in value">
{{row.city}}
我在博客上写了一个完整的解决方案:https://ianvink.wordpress.com/2018/06/11/angularjs-ng-repeat-with-groups/