Вопрос по документации angular > template variables
Вопрос в следующем, что имеется ввиду в последнем абзаце данного участка документации с оффсайта Angular:
When you declare the variable on an , the variable refers to a TemplateRef instance, which represents the template.
src/app/app.component.html
<ng-template #ref3></ng-template> <button (click)="log(ref3)">Log type of #ref</button>In this example, clicking the button calls the log() function, which outputs the value of #ref3 to the console. Because the #ref variable is on an , the value is TemplateRef.
The following is the expanded browser console output of the TemplateRef() function with the name of TemplateRef.
▼ ƒ TemplateRef() name: "TemplateRef" __proto__: Function
Откуда взялась функция TemplateRef(), когда это по идее класс, что они хотели донести? :D
Ответы (1 шт):
Стоит починать про функции-конструкторы. В данном случае, при вызове функции создается новый экземпляр класса TemplateRef().
P.S. Функции конструкторы принято называть с большой буквы.