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

231
Views
Angular 2: cambie el fondo de la aplicación en un día específico

Como huevo de pascua para mis colegas, me gustaría cambiar el fondo del sitio todos los años el 4 de mayo. Parece que no puedo entender cómo funcionaría eso. Hasta ahora he intentado esto para probar un método para hacerlo:

 var date = new Date(); if (date.getDate() == 26 && date.getMonth() == 4) { document.body.style.background = "red"; }

Lo coloqué en el ngOnInit del componente raíz, pero parece que no hace nada.

Si alguien pudiera arrojar algo de luz, sería muy apreciado. Me gustaría hacerlo como una especie de "regalo de despedida" para mis colegas, ya que es mi último día en la oficina.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

prueba esto

 var date = new Date(); if (date.getDate() == 26 && date.getMonth() == 3) { document.body.style.background = "red"; } //this works
over 4 years ago · Santiago Trujillo Report

0

Quizás una mejor manera es usar una clase específica para eso.

 <div [ngClass]="'bg-red': checkDate()">

CSS

 .bg-red { background-color: red; }

TS

 checkDate() { var date = new Date(); if(date.getDate() == 26 && date.getMonth() + 1 == 4){ return true; } }
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!