Skip to content

Commit a6b1b22

Browse files
author
mledour
committed
fix(layout): custom layoute service close#37
1 parent 366a4be commit a6b1b22

File tree

2 files changed

+12048
-7
lines changed

2 files changed

+12048
-7
lines changed

library/angular-admin-lte/src/lib/layout/layout.service.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
22
import { BehaviorSubject } from 'rxjs';
33

44
import { RoutingService } from '../services/routing.service';
5+
import { ActivatedRoute, ActivationStart, Router, RouterEvent } from '@angular/router';
56

67
@Injectable()
78
export class LayoutService {
@@ -15,7 +16,7 @@ export class LayoutService {
1516
* @param routingService [description]
1617
*/
1718
constructor(
18-
private routingService: RoutingService
19+
private router: Router
1920
) {
2021
this.init();
2122
}
@@ -26,12 +27,10 @@ export class LayoutService {
2627
* @return [description]
2728
*/
2829
private init() {
29-
this.routingService.onChange.subscribe((value) => {
30-
if (value && value[value.length - 1]) {
31-
if (this.customLayout === undefined || this.customLayout !== value[value.length - 1].data['disableLayout']) {
32-
this.isCustomLayout.next(!!value[value.length - 1].data['customLayout']);
33-
}
34-
this.customLayout = value[value.length - 1].data['customLayout'];
30+
this.router.events.subscribe((event: RouterEvent) => {
31+
if (event instanceof ActivationStart) {
32+
this.customLayout = event.snapshot.data.customLayout;
33+
this.isCustomLayout.next(!!this.customLayout);
3534
}
3635
});
3736
}

0 commit comments

Comments
 (0)