Answer the question
In order to leave comments, you need to log in
How to update Angular2 styles without reload?
I have a component y which is possible two themes and respectively 2 different css. Is it possible to somehow change the content of styleUrls or styles without reloading the page? I tried to fill in the localStorage variable with what theme I will have and then set a specific theme when loading the component, but this requires a page reload. Here is what I got
var theme = localStorage.getItem('color');
if(theme == "dark")
var color = require('../constructor/dark.bootstrap.min.css');
else
var color = require('../constructor/bootstrap.min.css');
var styles=require('./constructor_area.component.css');
@Component({
selector: 'constructor-area',
templateUrl: './constructor_area.component.html',
styles: [styles,color]
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question