Skip to content

Commit f086ae4

Browse files
authored
fix(notification-container): Fix wrong ngFor trackby implementation
- Fix wrong ngFor trackby implementation by replacing the direct value access with a class method Closes #12.
1 parent dc33d1a commit f086ae4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/components/notifier-container.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ul>
2-
<li class="x-notifier__container-list" *ngFor="let notification of notifications; trackBy: notification?.id">
2+
<li class="x-notifier__container-list" *ngFor="let notification of notifications; trackBy: identifyNotification;">
33
<x-notifier-notification
44
[notification]="notification"
55
(ready)="onNotificationReady( $event )"

src/components/notifier-container.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ export class NotifierContainerComponent implements OnDestroy, OnInit {
9696
}
9797
}
9898

99+
/**
100+
* Notification identifier, used as the ngFor trackby function
101+
*
102+
* @param {number} index Index
103+
* @param {NotifierNotification} notification Notifier notification
104+
* @returns {string} Notification ID as the unique identnfier
105+
*/
106+
public identifyNotification( index: number, notification: NotifierNotification ): string {
107+
return notification.id;
108+
}
109+
99110
/**
100111
* Event handler, handles clicks on notification dismiss buttons
101112
*

0 commit comments

Comments
 (0)