Set sass variable value in Angular 7

后端 未结 6 2662
悲哀的现实
悲哀的现实 2021-02-19 22:11

I have been working with angular for the last few weeks, and now I have a requirement to dynamically style a public site. The site admin set various color codes as well as a log

6条回答
  •  一向
    一向 (楼主)
    2021-02-19 22:27

    First of all, in ASP .NET, it might be not bad to have a db hold your styles and other front end related assets. This is because it is a Server Side Rendering framework. On the other hand, in Angular, it is client side (with the exception of Angular Universal, but you'll still have to expect working with things the same way on it). Even with translations (i18n or custom), in Angular world, it is most likely stored on the front end and not from the back (db or so). So you'll have to go and have your "theme"'s stored in a certain manner you prefer and make your way to switching between them dynamically with Angular. You can of course store the keys/variables for the styles/themes but their actual CSS values (classes and such) should be stored on the front end.

    Try to see this simple example from CSS vars in use while dynamically setting app theme (Angular). This is only just one way and there are lots of ways to do this and you might have to look for your personal preference.

提交回复
热议问题