Safe Traversal Operator
When you are dealing with complex object, the property may be null or undefined.
task = {
assignee: null
}
<span>{{task.assignee.name}}</span> //error occurs
Solution 1
<span *ngIf="task.assignee">{{task.assignee.name}}</span>
Solution 2
- If assignee is null or undefined angular is going to ignore this otherwise it is going to render the name value of the assignee
<span>{{task.assignee?.name}}</span>