applyCssRules(cssRules: string) { // Sanitize and apply the CSS rules const sanitizedCssRules = this.sanitizer.bypassSecurityTrustStyle(cssRules); // Insert the sanitized CSS rules into the <style> tag const styleElement = document.querySelector('style'); if (styleElement) { styleElement.innerHTML = sanitizedCssRules.toString(); } }import { DomSanitizer } from '@angular/platform-browser'; constructor(private sanitizer: DomSanitizer) {}<button (click)="applyCssRules('body { background-color: red; }')">Apply CSS Rules</button>