Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
How to render inner Css - Angular

I have an object "Content" contains two properties:

Content:{
html:string;
css:string
}

and I need to render a div depending on this object, for the html I could do that using:

<div [innnerHtml]="Content.html"></div>

but I couldn't render the css of the object. Content example:

Content:{
html:"<p>test rendering the object</p> <br> <div class="div1"></div>",
css:"p{color:red} .div1{background-color:black}"
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use ngStyle tag directives.

Ex:

<div [ngStyle]='style.css' [innnerHtml]="Content.html"></div>
about 4 years ago · Juan Pablo Isaza Report

0

The solution for me was appending the style content programmatically, like this:

ngOnInit() {
  const css = 'a {color: pink;}';
  const head = document.getElementsByTagName('div')[0];
  const style = document.createElement('style');
  style.type = 'text/css';
  style.appendChild(document.createTextNode(css));
  head.appendChild(style);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!