Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to do conditional rendering in angular

Hello everyone I’m trying to display different color based on variable value… My code looks like this :

 <nb-card accent = "a.zahtjevStatusNaziv == 'Kreiran' ? 'info' : 'success'" >
                  <nb-card-body>
                    <label class="label">Kreator napomene:</label><br>
                    <p>{{a.imeKreatora}}</p>      
                    <label class="label">Napomena:</label><br>
                    <p>{{!a.napomena ? "Prilikom ove akcije nije dodana napomena" : a.napomena}}</p>
                    <label class="label">Datum kreiranja napomene:</label><br>
                    <p>{{a.datumKreiranja | date:'dd. MM. YYYY. HH:mm'}}</p>
                    <label class="label">Poslovni proces:</label><br>
                    <p>{{a.poslovniProcesDokumenta.opis}}</p>
                    <label class="label">Status dokumenta:</label><br>
                    <p>{{a.zahtjevStatusNaziv}}</p>
                  </nb-card-body>
              </nb-card>

I tried ngIf but when using ngIf I need to copy this whole block of code, so I would like only accent value (inside nb-card) to be changed:

<nb-card accent = "a.zahtjevStatusNaziv == 'Kreiran' ? 'info' : 'success'" >

Appreciate if someone can advise. Thank you in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It should look something like

<nb-card [accent] = "a.zahtjevStatusNaziv == 'Kreiran' ? 'info' : 'success'" >
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading