Angular 6 - ERROR TypeError: Cannot read property 'value' of undefined

前端 未结 3 1464
你的背包
你的背包 2020-12-16 05:11

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

3条回答
  •  盖世英雄少女心
    2020-12-16 05:31

    Just use

    {{ joke?.value }}

    Your joke object doesn't have the value until the API response arrives. Thus use ? to apply the null check until the response arrives.

提交回复
热议问题