-2

what does means "?" in the following code:

  <span [style.text-decoration]="lineThrough">
     {{prefix}} {{hero?.name}}
  </span>

I don't understand the "?" in {{hero?.name}}. This code is in documentation of Angular: https://angular.io/guide/template-syntax#custom-events-with-eventemitter

Thanks

  • Its called the safe navigation operator. It makes sure that `name` property is only accessed if `hero` is defined (not null) – FAISAL Mar 11 '18 at 22:26

1 Answers1

1

From documentation:

The Angular safe navigation operator (?.) is a fluent and convenient way to guard against null and undefined values in property paths.

Read doc

KarlR
  • 1,545
  • 12
  • 28