<p>{{object.object2.object3.field1}}</p>
I have many <p>
filled with objects that have an object which have an object that might have field and in any case object
or object2
or object3
or field
can be null
or undefined
. How to deal with this correctly?
If I try to put an ngIf
for each and every value my view will get crazy.
you may try below,
<p>{{object?.object2?.object3?.field1}}</p>
Read more about Safe navigation operator here.
Hope this helps!!