Skip to content

Commit

Permalink
fix(notification-container): Fix wrong ngFor trackby implementation
Browse files Browse the repository at this point in the history
- Fix wrong ngFor trackby implementation by replacing the direct value access with a class method

Closes #12.
  • Loading branch information
dominique-mueller committed Apr 3, 2017
1 parent dc33d1a commit f086ae4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/notifier-container.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
<li class="x-notifier__container-list" *ngFor="let notification of notifications; trackBy: notification?.id">
<li class="x-notifier__container-list" *ngFor="let notification of notifications; trackBy: identifyNotification;">
<x-notifier-notification
[notification]="notification"
(ready)="onNotificationReady( $event )"
Expand Down
11 changes: 11 additions & 0 deletions src/components/notifier-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ export class NotifierContainerComponent implements OnDestroy, OnInit {
}
}

/**
* Notification identifier, used as the ngFor trackby function
*
* @param {number} index Index
* @param {NotifierNotification} notification Notifier notification
* @returns {string} Notification ID as the unique identnfier
*/
public identifyNotification( index: number, notification: NotifierNotification ): string {
return notification.id;
}

/**
* Event handler, handles clicks on notification dismiss buttons
*
Expand Down

0 comments on commit f086ae4

Please sign in to comment.