Browse Source

Added TrackBy in main menu

pull/3463/head
Vladyslav_Prykhodko 6 years ago
parent
commit
3adbb94e06
  1. 2
      ui-ngx/src/app/modules/home/menu/menu-toggle.component.html
  2. 4
      ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts
  3. 2
      ui-ngx/src/app/modules/home/menu/side-menu.component.html
  4. 5
      ui-ngx/src/app/modules/home/menu/side-menu.component.ts

2
ui-ngx/src/app/modules/home/menu/menu-toggle.component.html

@ -24,7 +24,7 @@
[ngClass]="{'tb-toggled' : sectionActive()}"></span>
</a>
<ul id="docs-menu-{{section.name | nospace}}" class="tb-menu-toggle-list" [ngStyle]="{height: sectionHeight()}">
<li *ngFor="let page of section.pages">
<li *ngFor="let page of section.pages; trackBy: trackBySectionPages">
<tb-menu-link [section]="page"></tb-menu-link>
</li>
</ul>

4
ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts

@ -44,4 +44,8 @@ export class MenuToggleComponent implements OnInit {
return '0px';
}
}
trackBySectionPages(index: number, section: MenuSection){
return section.name;
}
}

2
ui-ngx/src/app/modules/home/menu/side-menu.component.html

@ -16,7 +16,7 @@
-->
<ul fxFlex fxLayout="column" fxLayoutAlign="start stretch" class="tb-side-menu">
<li *ngFor="let section of menuSections$| async" [ngSwitch]="section.type === 'link'">
<li *ngFor="let section of menuSections$ | async; trackBy: trackByMenuSection" [ngSwitch]="section.type === 'link'">
<tb-menu-link *ngSwitchCase="true" [section]="section"></tb-menu-link>
<tb-menu-toggle *ngSwitchCase="false" [section]="section"></tb-menu-toggle>
</li>

5
ui-ngx/src/app/modules/home/menu/side-menu.component.ts

@ -16,6 +16,7 @@
import { Component, OnInit } from '@angular/core';
import { MenuService } from '@core/services/menu.service';
import { MenuSection } from '@core/services/menu.models';
@Component({
selector: 'tb-side-menu',
@ -29,6 +30,10 @@ export class SideMenuComponent implements OnInit {
constructor(private menuService: MenuService) {
}
trackByMenuSection(index: number, section: MenuSection){
return section.name;
}
ngOnInit() {
}

Loading…
Cancel
Save