I have this function to load stylesheet based on user's choice 'en' or 'ar':
addStyleSheet(lang: string) {
let headID = document.getElementsByTagName('head')[0];
let link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.id = 'widget_styles';link.type = 'text/css';
headID.appendChild(link);
if (lang == "ar") {
link.href = AppGlobals.APP_URL + './assets/css/bootstrap-rtl.css';
}
else if (lang == "en") {
link.href = AppGlobals.APP_URL + './assets/css/bootstrap.css';
}
}
My default language is English so the first page is working fine, also the first 'ar' choice fine and success to load 'bootstrap-rtl', but when I press 'en' again, the 'bootstrap-rtl' is already loaded so the design crash, I tried to unlink the css file using removeChild
but it doesn't work fine, any ideas?