Cannot read property 'title' of undefined, but title is displayed

前端 未结 2 503
太阳男子
太阳男子 2021-01-14 02:42

I\'m new with angular 4 , and I\'m trying to build my first application.

The title is displayed in the screen but get this error in the console :<

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-14 03:42

    You need to add safe operator in HTML to check if the value is present, this will avoid the above error if the value is not present

    {{ yourObj?.title }}

提交回复
热议问题