menu

Questions & Answers

Ionic add sheet style dynamically

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

Comments:
2023-01-22 00:20:02
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.
2023-01-22 00:20:02
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.
2023-01-22 00:20:02
@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
Answers(0) :