JPA ng-repeat filer - multiple id as one
I have joined two tables at this point. And it prints the code like this:
1
7
1
8
1
9
2
2
3
4
5
5
6
I am using angularjs ng-repeat to do something. My goal is to look like this:
1
7
8
9
2
3
4
5
6
My code:
<div id="menuList">
<ul class="menuNav">
<li class="menuList_Slide" ng-repeat="x in names">
<div>
<a href="category.html?categoryid={{x.parentid}}" target="_self">{{x.parentid}}</a>
</div>
<div>
<ul id="subCategories" ng-if="target == x.parentid">
<li>
<a href="category.html?subcategoryid={{x.id}}" target="_self">{{x.childid}}</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
Can the ng-repeat filter be used to do what?
+3
source to share
1 answer
This might solve your problem by putting ng-if
and checking the last item to be the same or not like doingng-if="names[$index-1].parentid != x.parentid"
Markup
<div id="menuList">
<ul class="menuNav">
<li class="menuList_Slide" ng-repeat="x in names">
<div ng-if="names[$index-1].parentid != x.parentid">
<a href="category.html?categoryid={{x.parentid}}" target="_self">{{x.parentid}}</a>
</div>
<div>
<ul id="subCategories" ng-if="target == x.parentid">
<li>
<a href="category.html?subcategoryid={{x.id}}" target="_self">{{x.childid}}</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
+1
source to share