I want to add this import
<link rel="stylesheet" href="./assets/sass/style.scss">
<link rel="stylesheet" href="./assets/sass/plugins.scss">
by condition to index.html in angular
but it's not work
I want to change style to rtl or ltr by selected language so i change import scss file in index.html
style rtl is
<link rel="stylesheet" href="./assets/sass/style.angular.scss">
<link rel="stylesheet" href="./assets/css/style.rtl.css">
style ltr is
<link rel="stylesheet" href="./assets/sass/style.scss">
<link rel="stylesheet" href="./assets/sass/plugins.scss">
Please trying using logical properties in css, since it eliminates the need to write 2 different stylesheets for direction. e.g: instead of saying
padding-right: 1rem;
you can saypadding-inline-start: 1rem;
. Thepadding-inline-start
looks at the direction your line starts(in this case you are in rtl mode) sopadding-inline-start
is equal topadding-right
.But if you insist that you want to load different styles based on your language, you have to follow these steps:
In your angular.json(or project.json) add these styles in this format:
As you can see, these styles have
"inject": false
, meaning they will not be added to html's link section by default. You are just saying that you are gonna have 2 lazy loaded files in this part.next you have add these styles to your html. Make a new service, in that service you have to write a code like this:
name of your style should be the name you assigned them in the previous step. And you should a conditional state that which style should be added.