bixi
Version:
企业级中后台前端解决方案
60 lines (55 loc) • 1.51 kB
text/typescript
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input,
Optional,
TemplateRef,
ViewEncapsulation
} from '@angular/core';
import { BixiLayoutService } from '../layout.service';
import { IBreadcrumb } from '../layout.type';
export class BixiHeaderComponent {
logoSmall: string;
logoLarge: string;
breadcrumbs: string | TemplateRef<void>;
tools: string | TemplateRef<void>;
open: boolean = true;
breads: IBreadcrumb[];
logo: string = '';
constructor(
public cdr: ChangeDetectorRef,
private layoutService: BixiLayoutService
) {
this.layoutService.openChange.subscribe((open: boolean) => {
this.open = open;
if (this.cdr) {
this.cdr.markForCheck();
}
});
this.layoutService.breadcrumb$.subscribe((breads: IBreadcrumb[]) => {
this.breads = breads;
if (this.cdr) {
this.cdr.markForCheck();
}
});
}
get logoClass() {
return this.open ? 'bixi-layout-header-logo-full' : 'bixi-layout-header-logo-small';
}
onOpenChange() {
this.layoutService.toggleMenu();
}
}