I've got observable object called user, so:
<ng-container *ngIf="auth.user$ | async as user;">
{{user.displayName}}
</ng-container>
my JSON object looks like:
"id":"MwdM8bak78eE1omf6u04KtqlE2X2",
"anonymous":false,
"cardTokens":{
"EtVcNxAfm00":{
"4digits":4123,
"Vendor":"Visa"
}
},
"displayName":"User",
"role":"user",
and i want to show all of users cards, so im using:
<ng-container *ngIf="auth.user$ | async as user; else login">
{{user.displayName}}
<ion-item *ngFor="let card of user.cardTokens;">
{{card.4digits}}
</ion-item>
</ng-container>
I see user name, but card tokens show me nothing. what should i do to show cards token array?
cardTokensis not an Array but a JavaScript Object. JS Objects are not iterable which is why you need to use eitherObject.keys()or as @Adrita Sharma pointed out, thekeyvaluepipe to be able to iterate.cardTokensis NOT an array here. It is an object. You can use the keyvalue pipe for instance to retrieve an iterable key-value pair