Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make group of data using Angular filter

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.11k
    Comment on it

    Angular JS is most of the newest technology we are learning these days, By using of angular JS you can do some really fast operation that happens in realtime.

    We'll consider an example of making group by of elements if array. example having schools and it's students, Some name are common and schools are different

    $scope.boys= [ {school: 'abc', name: 'Mack'},  {school: 'def', name: 'John'},  {school: 'xyz', name: 'Rihon'},
      {school: 'uvw', name: 'John'},  {school: 'jkml', name: 'Rihon'}];
    

    And your HTML will go like this:-

    <ul ng-repeat="(key, value) in boys | groupBy: 'name'">   Group name: {{ key }}  <li ng-repeat="boys in value">  boys: {{ boys.name }}   </li></ul>
    

    Now you'll see the results from the $boys array are now filtered by grouping

    Output:-

    Group name: Mack
    * school: abc
    Group name: Rihon
    * school: xyz
    * school: jkml
    Group name: John
    * school: def
    * school: uvw
    

    And there are still several other features in Angular Js that are really excellent.

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: