Commit 3adbb94e062cb6ebad9815314bb8ca5d0b2078eb

Authored by Vladyslav_Prykhodko
1 parent 6a4c2791

Added TrackBy in main menu

... ... @@ -24,7 +24,7 @@
24 24 [ngClass]="{'tb-toggled' : sectionActive()}"></span>
25 25 </a>
26 26 <ul id="docs-menu-{{section.name | nospace}}" class="tb-menu-toggle-list" [ngStyle]="{height: sectionHeight()}">
27   - <li *ngFor="let page of section.pages">
  27 + <li *ngFor="let page of section.pages; trackBy: trackBySectionPages">
28 28 <tb-menu-link [section]="page"></tb-menu-link>
29 29 </li>
30 30 </ul>
... ...
... ... @@ -44,4 +44,8 @@ export class MenuToggleComponent implements OnInit {
44 44 return '0px';
45 45 }
46 46 }
  47 +
  48 + trackBySectionPages(index: number, section: MenuSection){
  49 + return section.name;
  50 + }
47 51 }
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <ul fxFlex fxLayout="column" fxLayoutAlign="start stretch" class="tb-side-menu">
19   - <li *ngFor="let section of menuSections$| async" [ngSwitch]="section.type === 'link'">
  19 + <li *ngFor="let section of menuSections$ | async; trackBy: trackByMenuSection" [ngSwitch]="section.type === 'link'">
20 20 <tb-menu-link *ngSwitchCase="true" [section]="section"></tb-menu-link>
21 21 <tb-menu-toggle *ngSwitchCase="false" [section]="section"></tb-menu-toggle>
22 22 </li>
... ...
... ... @@ -16,6 +16,7 @@
16 16
17 17 import { Component, OnInit } from '@angular/core';
18 18 import { MenuService } from '@core/services/menu.service';
  19 +import { MenuSection } from '@core/services/menu.models';
19 20
20 21 @Component({
21 22 selector: 'tb-side-menu',
... ... @@ -29,6 +30,10 @@ export class SideMenuComponent implements OnInit {
29 30 constructor(private menuService: MenuService) {
30 31 }
31 32
  33 + trackByMenuSection(index: number, section: MenuSection){
  34 + return section.name;
  35 + }
  36 +
32 37 ngOnInit() {
33 38 }
34 39
... ...