If you're looking to dynamically load a CSS file, there's a simple way to do it. Let's say you have "style1.css" and "style2.css" in your assets folder. All you need to do is add the following code snippet to your app.component.html:
<link rel="stylesheet" [href]='myStyle'>
...rest of tags...
//In your app.component.ts
myStyle="assets/style1.css"
However, you may encounter an error stating "unsafe value used in a resource URL context." To resolve this issue, you'll need to use DomSanitizer like so:
Your app.component should look like this:
<link rel="stylesheet" [href]='sanitizer.bypassSecurityTrustResourceUrl(myStyle)'>
..rest of your div..
And don't forget to import DomSanitizer in your app.component.ts file:
import { DomSanitizer } from '@angular/platform-browser';
@Component({...})
export class AppComponent {
myStyle = "assets/style1.css";
constructor(public sanitizer: DomSanitizer) {}
}