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

309
Views
Importe condicionalmente archivos CSS en el componente Angular

Tengo diferentes archivos CSS (red.css, blue.css) en el único componente angular. ¿Cómo podemos importar el archivo css según la condición? Si mencioné el color como rojo, se debe importar el archivo red.css.

 this.activatedRoute.paramMap.subscribe(params=> { let color=params.get('color'); console.log(color); })
 red.css .my-container{ height: 100%; background-color: red; } blue.css .my-container{ height: 100%; background-color: blue; }
 <div class="my-container"> <h1 class="sideheading">URL that entered are processed for Theme Changing of the Page</h1> </div>

Múltiples archivos CSS y condición que toma el color como entrada y debe aplicar el archivo css de acuerdo con el color dado.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Parte CSS:

 .my-red-container{ height: 100%; background-color: red; } .my-blue-container{ height: 100%; background-color: blue; }

Parte angular: supongamos que tiene una variable mecanografiada llamada color y su valor es 'azul' o 'rojo

 <div [ngClass]="{'my-red-container': color === 'red', 'my-blue-container' : color === 'blue' }" ></div>
over 4 years ago · Santiago Trujillo Report

0

Parte CSS

 .my-red-container{ height: 100%; background-color: red; } .my-blue-container{ height: 100%; background-color: blue; }

Componente.html Parte

 <div [ngClass]="{color === 'red' ? 'my-red-container' : 'my-blue-container'}"> </div>
over 4 years ago · Santiago Trujillo 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!