I have problem with displaying data using *ngFor:
Auction object contains array of Bids.
export interface Auction {
descripton: string;
sellerId: string;
title: string;
price: number;
quantity: number;
bids: Bid[];
boughtByList: string[];
photoAlbum: PhotoAlbumModel;
auctionType: string;
starts: Date;
ends: Date;
comments: Comment[];
}
export class Bid {
constructor(public amount: number, public userName: string, public productTitle: string) {
}
}
I getting auction data in AuctionDetailsComponent
export class AuctionDetailsComponent implements OnInit, OnDestroy {
private title: string;
auction: Auction;
bid: Bid;
bidResponse: BidResponse;
highestBid: number;
coins: number;
private paramsSubscription: Subscription;
imageObjects: Array<object> = [];
constructor(private router: Router,
private activatedRoute: ActivatedRoute,
private productService: ProductService,
private cartService: CartService,
private authService: AuthenticationService,
private auctionService: AuctionService) {
}
ngOnInit(): void {
this.paramsSubscription = this.activatedRoute.params
.subscribe((params: Params) => {
this.title = params.title;
this.getAuction(this.title);
});
}
getAuction(title: string) {
this.auctionService
.get(title)
.subscribe((auction) => {
this.auction = auction;
this.setImageObject();
});
}
In auction-details.component.html I try to display Bid data using *ngFor
<div *ngFor="let bid of auction.bids">
<p>{{bid.userName}}</p>
</div>
Paragraphs are empty but in chrome debug there is a array.
and other Auction data - title, price displaying fine.
I don't know where is the problem.
