angularjs - Angular ng-repeat conditional wrap items in element (group items in ng-repeat) -


I am trying to group items in ng-repeat using a condition.

An example

<{name: 'AAA', time: '12: 05 '}, {name:' BBB ', time: '12: 10'}, { Name: 'CCC', Time: '13: 20 '}, {Name:' DDD ', Time: '13: 30'}, {Name: EEE ', Time: '13: 40'}, ...]

The 'time' field is actually a timestamp (13 99372207), but with the exact time the example production is easy to understand.

I am listing ng-repetitive items:

  & lt; Div ng-repeat = "data in r: orderby: sort: direction" & gt; & Lt; P & gt; {{R.name}} & lt; / P & gt; & Lt; / Div & gt;  

Also tried with:

  & lt; Div ng-repeat-start = "data in r: orderby: sort: direction" & gt; & Lt; / Div & gt; & Lt; P & gt; {{R.name}} & lt; / P & gt; & Lt; Div ng-repeat-end & gt; & Lt; / Div & gt;  

There is a valid output:

  & lt; Div class = "group-class" & gt; & Lt; Div & gt; & Lt; P & gt; AAA & lt; / P & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; P & gt; BBB & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "group-class" & gt; & Lt; Div & gt; & Lt; P & gt; CCC & lt; / P & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; P & gt; DDD & lt; / P & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; P & gt; EEE & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

My last option if my problem is not a simple solution, then data must be grouped and then it should be specified for the radius variable used in ng-repeat.

Any thoughts?

You can use the filter of the module group.
So that you can do something like this:

Usage: Archive | Group: Property
Use nested property with dot notation: property.nested_property
JS:

 

HTML:

  & lt; Group name: {{key}} & lt; li ng- repeat = "player in value" & gt; player: {{Player.name}}   

Result:
group name : Alpha
* Player: Gene
Group Name: Beta
* Player: George
* Player: Paula
Group Name: Gamma
* Players : Steve
* Player: Scruth

Update:


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -