Sharath
Sharath

Reputation: 691

Limiting number of items in ngrepeat and then adding up all others in to one using angularjs

I am listing out number of users the folder is shared as a Letter avatar in AngularJS and also I know how to limit it to a certain number. But can you help me how to display the remaining entries by adding up? For example, +1, +2, etc.

I am attaching a sample image and code for displaying the avatar in HTML file. Sample Img

Tag from HTML Page!

 <td class="project-people" ng-repeat="emp in employee">

   <img alt="image" class="img-circle" src="img/a2.jpg" 
        tooltip-placement="top" uib-tooltip="1{{emp.employee_Name}} is the owner">

   <ng-letter-avatar shape="round" avatarcustombgcolor dynamic="true"
        ng-repeat="usr in emp.employee_Shared |limitTo:2" data="{{usr.employee_Name}}">
   </ng-letter-avatar>
 </td>

Upvotes: 1

Views: 92

Answers (1)

Weedoze
Weedoze

Reputation: 13943

You can use User_Shared.length - yourLimit

In this case your limit is 2 but you can store it inside a variable that would be easier to maintain

<td class="project-people" ng-repeat="cli in client">
    <img alt="image" class="img-circle" src="img/a2.jpg" tooltip-placement="top" uib-tooltip="1{{cli.Owner_Name}} is the owner">
    <ng-letter-avatar shape="round" avatarcustombgcolor dynamic="true" ng-repeat="usr in cli.User_Shared |limitTo:2" data="{{usr.User_Name}}">
    </ng-letter-avatar>
    <ng-letter-avatar shape="round" avatarcustombgcolor dynamic="true" data="cli.User_Shared.length - 2"></ng-letter-avatar>
</td>

Upvotes: 2

Related Questions