File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
< ion-list inset no-lines class ="comments-list ">
2
- < ion-item *ngFor ="let comment of comments ">
2
+ < ion-item *ngFor ="let comment of comments; trackBy: trackByCommentId ">
3
3
< p class ="comment-head ">
4
4
< span class ="comment-author "> {{comment.author}}</ span >
5
5
< span class ="comment-score "> {{comment.score}} points</ span >
9
9
< button
10
10
*ngIf ="comment.replies.length "
11
11
ion-button clear
12
- (click) ="collapse (comment) "
12
+ (click) ="toggleExpanded (comment) "
13
13
class ="replies-toggle ">
14
14
< span > replies ({{comment.replies.length}})</ span >
15
- < ion-icon name ="ios-arrow-down " *ngIf ="! comment.collapsed "> </ ion-icon >
16
- < ion-icon name ="ios-arrow-forward " *ngIf ="comment.collapsed "> </ ion-icon >
15
+ < ion-icon name ="ios-arrow-down " *ngIf ="comment.expanded "> </ ion-icon >
16
+ < ion-icon name ="ios-arrow-forward " *ngIf ="! comment.expanded "> </ ion-icon >
17
17
</ button >
18
- < comments-list *ngIf ="comment.replies.length && ! comment.collapsed " [comments] ="comment.replies "> </ comments-list >
18
+ < comments-list *ngIf ="comment.replies.length && comment.expanded " [comments] ="comment.replies "> </ comments-list >
19
19
</ ion-item >
20
20
</ ion-list >
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ export class CommentsList {
10
10
11
11
constructor ( ) { }
12
12
13
- collapse ( comment ) {
14
- comment . collapsed = ! comment . collapsed ;
13
+ toggleExpanded ( comment ) {
14
+ comment . expanded = ! comment . expanded ;
15
+ }
16
+
17
+ trackByCommentId ( index , comment ) {
18
+ return comment . id ;
15
19
}
16
20
}
You can’t perform that action at this time.
0 commit comments