Angular 2 Templates - Safe Navigator for Methods

I successfully use angular 2 safe navigation operator for the properties mentioned in the documentation, for the property path , but a better approach for the method path?

myObj?.myMethod().myProperty

gives an exception:

EXCEPTION: TypeError: cannot read the myProperty property from null in [{{MyObj? .MyMethod (). MyProperty}}

+4
source share
1 answer

In javascript quote from w3schools :

A JavaScript method is a property that contains a function definition.

I see no problems why it should not work as follows:

{{myObj?.myMethod()?.myProperty}} 

From Angular.io cheat sheet :

<p>Employer: {{employer?.companyName}}</p>

(?) , , undefined,

+9

All Articles