Skip to content

Commit

Permalink
fix(module:menu): fix submenu ExpressionChangedAfterItHasBeenCheckedE…
Browse files Browse the repository at this point in the history
…rror (#368)

close #367
  • Loading branch information
vthinkxie authored Sep 23, 2017
1 parent 1a997c2 commit 10989ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/menu/nz-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export class NzMenuComponent implements OnChanges, AfterViewInit {
@Input() nzMode: NzMode = 'vertical';
@Input() nzTheme: 'light' | 'dark' = 'light';
@Input() nzClickActive = true;

@Input()
get nzInlineCollapsed(): boolean {
return this._nzInlineCollapsed;
}

set nzInlineCollapsed(state: boolean) {
this._nzInlineCollapsed = state;
if (!this.isInit) {
Expand Down Expand Up @@ -143,7 +145,7 @@ export class NzMenuComponent implements OnChanges, AfterViewInit {
}

reductionSubMenus() {
this._subMenusOpenIndex.forEach(i => this.subMenus[i].nzOpen = true);
this._subMenusOpenIndex.forEach(i => this.subMenus[ i ].nzOpen = true);
this._subMenusOpenIndex = [];
}

Expand All @@ -155,4 +157,10 @@ export class NzMenuComponent implements OnChanges, AfterViewInit {
this.subMenus.forEach(subMenu => subMenu.isInDropDown = value);
});
}

setHasSubMenu(value: boolean) {
setTimeout(_ => {
this.hasSubMenu = value;
})
}
}
2 changes: 1 addition & 1 deletion src/components/menu/nz-submenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterViewInit {


constructor(public nzMenuComponent: NzMenuComponent, public cd: ChangeDetectorRef) {
this.nzMenuComponent.hasSubMenu = true;
this.nzMenuComponent.setHasSubMenu(true);
this.nzMenuComponent.subMenus.push(this);
}

Expand Down

0 comments on commit 10989ae

Please sign in to comment.