0

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!

1
  • 1
    You should use [accent] instead (see the extra brackets). So the whole thing should look like this: [accent]="a.zahtjevStatusNaziv == 'Kreiran' ? 'info' : 'success'" Commented Oct 20, 2022 at 6:38

1 Answer 1

2

It should look something like

<nb-card [accent] = "a.zahtjevStatusNaziv == 'Kreiran' ? 'info' : 'success'" >
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.