Browse Source

removed unnecessary template elements from dynamic layout

pull/10864/head
mehmet-erim 5 years ago
parent
commit
bd3d8c494a
  1. 15
      npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts

15
npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts

@ -1,4 +1,4 @@
import { Component, Injector, Optional, SkipSelf, Type } from '@angular/core'; import { Component, Injector, isDevMode, Optional, SkipSelf, Type } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { eLayoutType } from '../enums/common'; import { eLayoutType } from '../enums/common';
import { ABP } from '../models'; import { ABP } from '../models';
@ -13,13 +13,7 @@ import { TreeNode } from '../utils/tree-utils';
@Component({ @Component({
selector: 'abp-dynamic-layout', selector: 'abp-dynamic-layout',
template: ` template: ` <ng-container *ngIf="isLayoutVisible" [ngComponentOutlet]="layout"></ng-container> `,
<ng-container *ngTemplateOutlet="layout ? componentOutlet : routerOutlet"></ng-container>
<ng-template #routerOutlet><router-outlet></router-outlet></ng-template>
<ng-template #componentOutlet
><ng-container *ngIf="isLayoutVisible" [ngComponentOutlet]="layout"></ng-container
></ng-template>
`,
providers: [SubscriptionService], providers: [SubscriptionService],
}) })
export class DynamicLayoutComponent { export class DynamicLayoutComponent {
@ -47,7 +41,10 @@ export class DynamicLayoutComponent {
private routerEvents: RouterEvents, private routerEvents: RouterEvents,
@Optional() @SkipSelf() dynamicLayoutComponent: DynamicLayoutComponent, @Optional() @SkipSelf() dynamicLayoutComponent: DynamicLayoutComponent,
) { ) {
if (dynamicLayoutComponent) return; if (dynamicLayoutComponent) {
if (isDevMode) console.warn('DynamicLayoutComponent must be used only in AppComponent.');
return;
}
this.route = injector.get(ActivatedRoute); this.route = injector.get(ActivatedRoute);
this.router = injector.get(Router); this.router = injector.get(Router);
this.routes = injector.get(RoutesService); this.routes = injector.get(RoutesService);

Loading…
Cancel
Save