0

We have a JSON object and we do have a different requirement to display in a different form.

The object:

[
    {name: a1, marks:10},
    {name: b3, marks:10},
    {name: b2, marks:10},
    {name: c1, marks:10},
    {name: b1, marks:10},
    {name: a2, marks:10}
]

To display UI:

On click of sort by name

A: name: a1, name: a2, name: a3
B: name: b1, name: b2, name: b3
C: name: c1, name: c2, name: c3

And onclik of sort by marks (not to sort by name inside marks)

10: name: a2, name: c1, name: a3
11: name: a1, name: b2, name: b3
12: name: c1, name: a2, name: c3

Can anyone help please?

Have tried:

<div ng-repeat="letter in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']">
  <div class="folders_only col-xs-12"  ng-show="getFilesOfType(letter).length">
    <div>
      <span>{{letter}}</span>
    </div>
    <div ng-repeat='val in getFilesOfType(letter)'></div> 
  </div>
</div>

But problem is I have json object which gets more data on scrolling down each time, so new data doesnt reflect in UI

4
  • What did you try, until now? Commented May 24, 2016 at 7:06
  • Just see this codepen.io/sevilayha/pen/AmFLE example and try it on your own. Commented May 24, 2016 at 7:09
  • What i understand from your question is you need dynamic sort based on some variable. Check this link: stackoverflow.com/questions/29635796/… Commented May 24, 2016 at 7:11
  • @Luckyy Your question is not clear. You want to sort an array. Again you are saying I have json object which gets more data on scrolling down each time, so new data doesnt reflect in UI. What do you mean by new data doesnt reflect in UI ? And, What does your getFilesOfType(letter) return? It will be better if you can create fiddle/plunker. Commented May 24, 2016 at 9:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.