This my html code and below in my ts code ,
<div id="address" class="bg-light rounded mt-3">
<div class="h5 font-weight-bold text-primary"> Customer Feedback </div>
<div class="d-md-flex justify-content-md-start align-items-md-center pt-3">
<div class="mr-auto"> <b>Purchase Feedback </b>
<p class="text-justify text-muted">{{description}}</p>
</div>
</div>
</div>
I am getting this feedback from an api which I am storing in localstorge , but sometime its very much possible that this.feedbackdetails.description might be null , when the data is available it works fine but data is not available it gives error something like this
this.feedbackdetails = JSON.parse(localStorage.getItem('feedback'))
if (this.feedbackdetails.description != null) {
this.description = this.feedbackdetails.description
} else {
this.description = 'NO FEEDBACK PROVIDED'
}
ErrorMsg:-
TypeError: Cannot read property 'description' of null
at GetcutomerorderdetailsComponent.push../src/app/getcutomerorderdetails/getcutomerorderdetails.component.ts.GetcutomerorderdetailsComponent.ngOnInit (main.js:1407)
at checkAndUpdateDirectiveInline (vendor.js:56990)
at checkAndUpdateNodeInline (vendor.js:65246
Is there any way to handle this ?
*ngIf="{feedbackdetails}", also, why do you havethiss.descriptionandthis.descriptiondata?