Skip to content

Commit 0e806e1

Browse files
Domainvvalorkin
authored andcommitted
feat(demo): opportunity to change bs theme by url query (#4870)
1 parent 3a17cc3 commit 0e806e1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

demo/src/app/common/sidebar/sidebar.component.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
12
import { Component, Inject, OnDestroy, Renderer } from '@angular/core';
2-
import { NavigationEnd, Router } from '@angular/router';
3+
import { DOCUMENT } from '@angular/common';
4+
35
import { isBs3, setTheme } from 'ngx-bootstrap/utils';
46
import { routes } from '../../app.routing';
57
import { StyleManager } from '../../theme/style-manager';
68
import { ThemeStorage } from '../../theme/theme-storage';
7-
import { DOCUMENT } from '@angular/common';
9+
810
import { Subscription } from 'rxjs';
911

1012
const _bs3Css = 'assets/css/bootstrap-3.3.7/css/bootstrap.min.css';
@@ -28,13 +30,15 @@ export class SidebarComponent implements OnDestroy {
2830
scrollSubscription: Subscription;
2931

3032
constructor(
31-
public styleManager: StyleManager,
33+
private activatedRoute: ActivatedRoute,
34+
private renderer: Renderer,
3235
private router: Router,
3336
private themeStorage: ThemeStorage,
34-
private renderer: Renderer,
37+
public styleManager: StyleManager,
3538
@Inject(DOCUMENT) private document: any
3639
) {
37-
const currentTheme = this.themeStorage.getStoredTheme();
40+
const themeFromUrl = this.activatedRoute.snapshot.queryParams._bsVersion;
41+
const currentTheme = themeFromUrl || this.themeStorage.getStoredTheme();
3842
if (currentTheme) {
3943
this.installTheme(currentTheme);
4044
}

0 commit comments

Comments
 (0)