ソースを参照

fix(styleguide): fixed theme switching in style guide

Torkel Ödegaard 9 年 前
コミット
7b7ba46f12
1 ファイル変更6 行追加3 行削除
  1. 6 3
      public/app/features/styleguide/styleguide.ts

+ 6 - 3
public/app/features/styleguide/styleguide.ts

@@ -13,7 +13,7 @@ class StyleGuideCtrl {
   pages = ['colors', 'buttons'];
 
   /** @ngInject **/
-  constructor(private $http, $routeParams) {
+  constructor(private $http, private $routeParams, private $location) {
     this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
     this.page = {};
 
@@ -37,8 +37,11 @@ class StyleGuideCtrl {
   }
 
   switchTheme() {
-    var other = this.theme === 'dark' ? 'light' : 'dark';
-    window.location.href = window.location.href + '?theme=' + other;
+    this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
+    this.$location.search(this.$routeParams);
+    setTimeout(() => {
+      window.location.href = window.location.href;
+    });
   }
 
 }