AngularJS switch css theme on user selection

后端 未结 4 1558
情话喂你
情话喂你 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条回答
  •  -上瘾入骨i
    2020-12-19 16:13

    If you include all your themes at first load, them all of them have to be loaded by the browser. And it is not even clear if user will ever switch themes. So why should you load all of them. So here are few options.

    1. Ng-if

    Try to ad ng-if to link

    
    

    I am not sure if it will work but i have read somewhere that it worked for some people

    2. Visibility

    I am typing from ipad so ill be short.

    Create css file with something like this

    Body .container {display:none}
    Body .loader {display:block}
    

    Put all you content into container class div. create sibling div class loader and place loader animation there.

    Load/link this file first in the head. Then link your theme in every theme add cancelation of those rules.

    Body .container {display:block}
    Body .loader {display:none}
    

    So on the moment of css reload you will have a loader animation.

提交回复
热议问题