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 iterate an Object using *ngFor Angular

I have an array of objects that looks like

[
     {sn: 'N300W150726', merchantName: ' test', __typename: 'GetTpeByUser'}
     {sn: 'N300W150726', merchantName: 'alex', __typename: 'GetTpeByUser'}
     {sn: 'N300W150726', merchantName: 'alexa', __typename: 'GetTpeByUser'}
]

I want to display the merchantName in button text and send the sn through the function

<nb-card [size]="'medium'" *ngIf="!toggle">
      <nb-card-header>
        <div class="col-lg-6">Point de vente</div>
      </nb-card-header>
      <nb-card-body>
        <nb-list>
          <nb-list-item *ngFor="let item of nameUsersByTpe">
            <!-- FILTER ARRAY -->
            <button nbButton (click)="getTpeByUser(item.sn)">
              {{ item.merchantName}}
            </button>
          </nb-list-item>
        </nb-list>
      </nb-card-body>
    </nb-card>

this code returns nothing , is there any solution ??

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 :

Do you see totally nothing? Then check toggle variable. Is the list not showing? Then check the nameUsersByType Array. BTW: the array elements are not separated by commas. Is this true? Then look there for your answer

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