How to Solve Object is Possibly 'undefined'. In Angular And TypeScript

preview_player
Показать описание
This video is about fixing or solving the Angular or typescript issue object is possibily undefined.
With the release of TypeScript 3.7, optional chaining (the ? operator) is now officially available.

As such, you can simplify your expression to the following:

const data = change?.after?.data();

another way to to initialise your variable or to make it optional.
Рекомендации по теме
Комментарии
Автор

thanku for this but its not working for me. can you help ?
i've an object of a class type. this object is getting data from an api.
while accessing it in html, i'm getting the error.
TIA.

av