I\'m new to Angular and Typescript and cannot get to the bottom of this console error: \"ERROR TypeError: Cannot read property \'value\' of undefined\"
I\'m calling
Angular 7 - ERROR TypeError: Cannot read property 'value' of undefined
You can check for the object value by using the ?
operator.
Example:
<div> {{ joke?.value }} </div>
You can use *ngIf until getting resopnse
below is the sample,
<div *ngIf="joke">{{ joke.value }}</div>
Just use
<div>{{ joke?.value }}</div>
Your joke
object doesn't have the value until the API response arrives. Thus use ?
to apply the null check until the response arrives.