F
F
Flopikpl2017-01-12 23:29:52
Angular
Flopikpl, 2017-01-12 23:29:52

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

2 answer(s)
A
Alexander Belov, 2017-01-12
@AlexanderBelov

livereload()

O
ozknemoy, 2017-01-13
@ozknemoy

webpack dev server with Hot Module Replacement

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question