为什么Color Theming App在重新加载时恢复默认值?

时间:2016-12-19 16:11:20

标签: javascript jquery css angularjs ionic-framework

案例

所以我按照instruction进行了操作,即使在更改页面时效果也很好。但是,当页面重新加载时,我回到默认状态,我想出了如何保存此设置(甚至在本地),并且在重新加载时它不会改变,直到用户仅在设置部分更改它。我尝试使用$ window.localstorage保存一些方法,但它不起作用。

  $scope.styles = [
          {
            name: "Default",
            url: "style.css"
          },
          {
            name: "Positive",
            url: "positive.css"
          },
          {
            name: "Energized",
            url: "energized.css"
          },
          {
            name: "Fire",
            url: "fire.css"
          },
          {
            name: "Mint",
            url: "mint.css"
          },
          {
            name: "Violet",
            url: "violet.css"
          },
          {
            name: "Grass",
            url: "grass.css"
          },
          {
            name: "Pink",
            url: "pink.css"
          },
          {
            name: "Dark",
            url: "dark-style.css"
          }
        ];

        /**
         * Change the style.
         * @param style The selected style.
         */
        $scope.changeStyle = function(style){
          if (style) {
          $rootScope.style = "css/" + style.url;
          $window.localStorage.styles = style;

        } else {
          $rootScope.style = "css/style.css"
        }
        };

这就是我称之为

的方式
<label class="item item-input ic-selected">
            <a class="icon icon-right ion-locked" style="margin-right: 10px;"></a>
            <select ng-options="style as style.name for style in styles" ng-change="changeStyle(style)" ng-model="style" >sadas
        </select>
          </label>

enter image description here

问题

如何将样式输入从ng-options保存到localstorage,以便在重新加载/刷新页面时调用它们?

0 个答案:

没有答案