AngularJS switch css theme on user selection

后端 未结 4 1577
情话喂你
情话喂你 2020-12-19 15:29

I downloaded the themes from bootswatch and I\'m trying to allow the user to switch the theme. When the theme is switched all the bootstap css temporarily goes away until th

4条回答
  •  星月不相逢
    2020-12-19 16:18

    I find it better to keep it simple, and there's no need to pre-load all the themes like other have suggested.

    Stick to a single tag with ng-href:

    
    

    And initialize myVar in your scope to "yeti" in the index controller:

    $scope.myTheme = 'yeti';
    $rootScope.$watch('myTheme', function(value) {
      if (value != undefined) {
        $scope.myTheme = value;
      }
    });
    

    The rest stays the same.

提交回复
热议问题