I have a specific need where numerous CSS files are stored on a public CDN server.
My Angular 17 application requires the ability to extract a value from a query parameter and then use that value to locate the corresponding CSS file on the CDN server in order to style the UI as per the specified CSS file name in the application's URL query parameter.
I have experimented with different methods such as utilizing HttpClient
to load the CSS file in the component's ngOnInit
function, as well as trying the APP_INITIALIZER
approach. While I can successfully load the CSS file, it does not seem to apply to the HTML elements.
In AngularJS, I was able to accomplish this using:
<link ng-href="https://<cdn-server-domain>/{{cssFileName}}.css">
Unfortunately, I have been unsuccessful in finding a working solution for this issue in Angular.
Your suggestions would be greatly appreciated.