Angular Component class attribute initialization and constructor execution order

As shown in the figure, the attribute initialization logic on line 13 of the Component class and the breakpoint in the constructor on line 17. Which line of code is executed first?

Observe in the debugger:

First execute the custom Component factory function to create a Component instance:

The 13th line of code is executed first:

Note this at this time:

Then the constructor is executed, this.product$ is already available, and the prototype is Observable:

To get more original articles by Jerry, please follow the public account "Wang Zixi":

Guess you like

Origin blog.csdn.net/i042416/article/details/108655065