Backend
I have used Django RestFrame work implemented one-many concept and my output was like
Frontend
In Front End i able to retrieve all data except tax_details.It was just returning as an Object like this.
Actually i'm new to this concept so i don't know how to over come from this.
Html
<div class="row">
<div class="col-md-12">
<nb-card>
<nb-card-header>
<span>Product Details</span>
<span style="padding-left:75%">
<button (click)="onButtonClick()" class="btn btn-success btn-sm text-right">Edit</button>
</span>
</nb-card-header>
<nb-card-body>
<div class="row">
<div class="col-sm-6">
<div class="header">
<div>
<h6>Product Name</h6>
</div>
<div class="detail font-w-dark">{{update.pro_name}}</div>
</div>
<div class="header">
<div>
<h6>Category</h6>
</div>
<div class="detail font-w-light">{{update.category}}</div>
</div>
<div class="header">
<div>
<h6>Sales price</h6>
</div>
<div class="detail font-w-light">{{update.sales}}</div>
</div>
<div class="header">
<div>
<h6>Cost</h6>
</div>
<div class="detail font-w-light">{{update.cost}}</div>
</div>
<div class="header">
<div>
<h6>Quantity Type</h6>
</div>
<div class="detail font-w-light">{{update.type_units}}</div>
</div>
<div class="header">
<div>
<h6>HSN CODE</h6>
</div>
<div class="detail font-w-light">{{update.hsn}}</div>
</div>
<div class="header">
<div>
<h6>Description</h6>
</div>
<div class="detail font-w-light">{{update.description}}</div>
</div>
</div>
<div class="col-sm-6">
<div class="header">
<div>
<h6>Is Taxable</h6>
</div>
<div class="detail font-w-light">
{{update.taxable}}</div>
</div>
<div class="header">
<div>
<h6>Is Details</h6>
</div>
<div class="detail font-w-light">
{{update.tax_details}}</div>
</div>
</div>
</div>
</nb-card-body>
</nb-card>
</div>
</div>
Component.ts
constructor(private themeService: NbThemeService,
private route: ActivatedRoute,
private breakpointService: NbMediaBreakpointsService,
private service: ProductsService,
private router: Router) {
this.breakpoints = this.breakpointService.getBreakpointsMap();
this.themeSubscription = this.themeService.onMediaQueryChange()
.subscribe(([oldValue, newValue]) => {
this.breakpoint = newValue;
});
this.route.params.subscribe(
params => {
this.user = params['id'];
});
this.service.get_update(this.user).subscribe(update => this.update = update,
error => console.log(error));
this.service.get_updatetax(this.user).subscribe(update1 => this.update1 = update1,
error => console.log(error));
this.update=([])
this.update1=([])
}
Here i have mentioned my Html, Component.ts and also output images So please tell me how get that data.
<div class="detail font-w-light">
<div *ngFor="let el of update.tax_details"</div>
<p> {{el.name}} {{el.percentage}} </p>
</div>
update.tax_details
is an array of objects, so you have to iterate over it and extract the required fields