Browse Source

move loadStyle to a method

pull/15085/head
Mahmut Gundogdu 4 years ago
committed by GitHub
parent
commit
7d6cf7940c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts

29
npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts

@ -8,6 +8,7 @@ import {
Output,
TemplateRef,
ViewEncapsulation,
OnInit
} from '@angular/core';
import { NzFormatBeforeDropEvent, NzFormatEmitEvent } from 'ng-zorro-antd/tree';
import { of } from 'rxjs';
@ -26,7 +27,7 @@ export type DropEvent = NzFormatEmitEvent & { pos: number };
encapsulation: ViewEncapsulation.None,
providers: [SubscriptionService],
})
export class TreeComponent {
export class TreeComponent implements OnInit {
dropPosition: number;
dropdowns = {} as { [key: string]: NgbDropdown };
@ -36,16 +37,8 @@ export class TreeComponent {
subscriptionService: SubscriptionService,
@Optional()
@Inject(DISABLE_TREE_STYLE_LOADING_TOKEN)
disableTreeStyleLoading: boolean | undefined,
) {
if (disableTreeStyleLoading) {
return;
}
const loaded$ = this.lazyLoadService.load(
LOADING_STRATEGY.AppendAnonymousStyleToHead('ng-zorro-antd-tree.css'),
);
subscriptionService.addOne(loaded$);
}
private disableTreeStyleLoading: boolean | undefined,
) { }
@ContentChild('menu') menu: TemplateRef<any>;
@ContentChild(TreeNodeTemplateDirective) customNodeTemplate: TreeNodeTemplateDirective;
@ -70,6 +63,20 @@ export class TreeComponent {
return of(false);
};
ngOnInit() {
this.loadStyle()
}
private loadStyle() {
if (disableTreeStyleLoading) {
return;
}
const loaded$ = this.lazyLoadService.load(
LOADING_STRATEGY.AppendAnonymousStyleToHead('ng-zorro-antd-tree.css'),
);
subscriptionService.addOne(loaded$);
}
onSelectedNodeChange(node) {
this.selectedNode = node.origin.entity;
if (this.changeCheckboxWithNode) {

Loading…
Cancel
Save