0

Why can I not add stylehseet dynamically between head tag of app ionic?

Thanks very much.

I'm using

<link type="text/css" rel="stylesheet" [href]="sanitizer.bypassSecurityTrustResourceUrl(cssUrl)"> 

but it's only working in app.component.html and not working in index.html

Thanks

Oybek
  • 7,016
  • 5
  • 29
  • 49
maudichili
  • 49
  • 1
  • 5
  • Stylesheets should not be dynamically replaced. If your css is small enough I recommend you combining all in one like `.style1 { /* all your css /* } .style2 { /* all other css /* }` and then change class for the container. – Oybek Jan 21 '23 at 21:21
  • Also, I recommend you adding more details. I guess, this is Angular ionic app, and your index.html is the main html file. You generally don't do such things in that html file in angular. – Oybek Jan 21 '23 at 21:23
  • @Oybek i have 3 sheet style (1500 lines for sheet). Yes, is Angular ionic app, and index.html is the main html file. This is for 3 option of theme. I managed to add the style sheet in the component with [href]= , but it doesn't work in general (it adds it in the body) and the styles don't work – maudichili Jan 21 '23 at 23:49
  • Check out [this](https://stackoverflow.com/questions/37730801/is-it-possible-to-dynamically-change-global-stylesheets-in-angular-2) question. Also, the `DOCUMENT` object seems to be moved to a different project. For that matter refer to [this](https://stackoverflow.com/questions/56826692/export-document-was-not-found-in-angular-platform-browser) question. – Oybek Jan 22 '23 at 18:35

0 Answers0