【发布时间】:2016-05-02 23:54:04
【问题描述】:
我有一个数组,其中包含 JSON 数组中的多个元素,
我可以通过执行category.language 来访问doing(JSON 中也很少有其他可以访问的元素,例如执行category.name、category.photo 等)
English, Russian, French, Russian, English
我想要做的是把重复的东西放在一起,最终得到:
English, Russian, French
不删除重复项,因为删除它们也会删除其他相关元素,例如 category.name... 具有其他不同的值。
目前我正在从 REST API 中获取,以下是我的代码:
Page.js
this.menuPages = {
pagination: '.swiper-pagination',
//need to have 1 or more (it should some how dynamic depending on the number of the unique items, i.e. sometimes should 1 slide per view, sometimes 10 slides per view )
slidesPerView: '1',
paginationClickable: true,
paginationBulletRender: function (index, className) {
console.log('print now2 : '+storeCategory[index]);
return '<span class="' + className + '">' + storeCategory[index] + '</span>';
}
}
页面.html
<ion-slides pager [options]="Pages">
<ion-slide *ngFor="#category of categories">
//put the duplicates with each other, to have one element or more in every slide(page)
<ion-row>
<ion-col>
<div class="title">{{category.name}</div>
<div class="subTitle"><br>{{category.photo}}</div>
</ion-col>
</ion-row>
</ion-slide>
</ion-slides>
我相信通过page.html 或page.js 玩耍应该可以解决问题!我希望你能提出一些想法来解决它!
【问题讨论】:
标签: javascript json angular ionic2 swiper