【发布时间】:2016-01-29 22:54:14
【问题描述】:
我的ion-list 中有ng-class,如果用户单击一个项目,它会添加类selected。使用 collection-repeat 时的问题是它管理 DOM 并在我滚动时更改 selected 类。
<ion-list>
<ion-item collection-repeat="contact in contacts | filter:filters" class="contact" ng-click="pickContact($index, $element, this.contact)" ng-model="contactModel" ng-class="{'selected': contact.selectedContact}" toggle-contacts="selected" collection-item-height="150" collection-item-width="'33.3%'">
<div ng-if="contact.photo.type == 'img'" class="contact-img">
<img ng-src="{{contact.photo.value}}.png" alt="">
</div>
<div ng-if="contact.photo.type == 'text'" class="contact-text-placeholder">
{{contact.photo.value}}
</div>
<div class="contact-name">
{{contact.name}}
</div>
</ion-item>
</ion-list>
我怎样才能避免这种情况发生?我希望课堂坚持下去。
【问题讨论】: