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

356
Views
¿Cómo cambiar el número negativo de color de fuente, datos de números positivos de json con manillar?

Obtuve datos json de una API externa.

<h4>ChangePercent <span class="badge bg-secondary"> {{ stock.changePercent}} % </span></h4>

El código anterior es obtener json de datos de respuesta y se devuelve con el tipo de número, y usa el motor de plantilla con manillares rápidos para renderizar. Es trabajo, pero... quiero cambiar el color de fuente rojo si stock.changePercent < 0 , verde para stock.changePercent > 0

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede renderizar condicionalmente en handlebarsjs

Modelo:

 <h4>ChangePercent <span class="badge bg-secondary" {{#if stockChangeSmallerThanZero}}style="color: red;"{{/if}}> {{ stock.changePercent}} % </span></h4>

Variable

 { stockChangeSmallerThanZero: true, }

Área de juegos en línea: https://handlebarsjs.com/playground.html#format=1&currentExample=%7B%22template%22%3A%22%3Ch4%3EChangePercent%20%3Cspan%20class%3D%5C%22badge%20bg-secondary% 5C%22%20%7B%7B%23if%20stockChangeSmallerThanZero%7D%7Dstyle%3D%5C%22color%3A%20red%3B%5C%22%7B%7B%2Fif%7D%7D%3E%20%20% 7B%7B%20%cambio.stock%7D%7D%20%25%20%20%20%20%3C%2Fspan%3E%3C%2Fh4%3E%20%22%2C%22parciales%22%3A%5B% 5D%2C%22input%22%3A%22%7B%5Cn%20%20stockChangeSmallerThanZero%3A%20true%2C%5Cn%7D%5Cn%22%2C%22output%22%3A%22%3Ch4%3EChangePercent%20% 3Cspan%20clase%3D%5C%22insignia%20bg-secundario%5C%22%20estilo%3D%5C%22color%3A%20rojo%3B%5C%22%3E%20%20%20%25%20%20% 20%20%3C%2Fspan%3E%3C%2Fh4%3E%20%22%2C%22preparationScript%22%3A%22%22%2C%22handlebarsVersion%22%3A%224.7.7%22%7D

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!