2014-08-27 45 views
2

我想要实现餐馆列表。因此,我得到了谁处理这个JSON数据服务:按给定参数的角度+离子列表分隔符

var restaurants = [ 
{"ID":1,"Name":"Restaurant 5","Ort":"Frauenfeld"}, 
{"ID":2,"Name":"Restaurant Ban Kinnaree","Ort":"Diessenhofen"}, 
{"ID":3,"Name":"Falken – Pub, Bar, Restaurant & Motel","Ort":"Frauenfeld"}, 
{"ID":4,"Name":"Gasthaus zum goldenen Kreuz","Ort":"Frauenfeld"},........ 

现在在我的名单(我用的集合重复)应该有属性“的Ort”分隔。所以每当餐厅的“Ort”是例如。 “弗劳恩费尔德”它应该显示一个名为“弗劳恩费尔德”分隔,并显示在“弗劳恩费尔德所有餐馆的下面一些帮助将是惊人的

这是集合重复指令,我用:!

<div class="list"> 
    <a class="item my-item" 
     collection-repeat="restaurant in restaurants | filter:searchText" 
     collection-item-width="'100%'" 
     collection-item-height="getItemHeight(item, $index)" 
     ng-style="{height: getItemHeight(item, $index)}" 
     ng-href="#/detail/{{restaurant.ID-1}}"> 
     {{restaurant.Name}} 
     <p>{{restaurant.Ort}}</p> 
    </a> 
    </div> 

回答

3

你有很好的例如离子提供:

演示在Codepan

播放与ng-class="item-divider"ng-stile


<ion-content> 
    <div class="list"> 
     <a class="item my-item" 
     collection-repeat="item in getContacts()" 
     collection-item-height="getItemHeight(item)" 
     collection-item-width="getItemWidth(item)" 
     ng-href="https://www.google.com/#q={{item.first_name + '+' + item.last_name}}" 
     ng-style="{'line-height': getItemHeight(item) + 'px'}" 
     ng-class="{'item-divider': item.isLetter}"> 
     <img ng-if="!item.isLetter" ng-src="http://placekitten.com/60/{{55 + ($index % 10)}}"> 
     {{item.letter || (item.first_name+' '+item.last_name)}} 
     </a> 
    </div> 
    </ion-content> 

参考:

collectionRepeat