Exploring Angular DOM manipulation techniques using ViewContainerRef

I am trying to create a directive similar to ngIf https://stackblitz.com/edit/angular-auby7n I does not have much code there. So now my question here is

  1. When i inject ViewContainerRef inside this directive, what dom element does it represent (if any) ?
  2. Since when we use a structural directive that gets wrapped inside an ng-template and the directive gets applied to the ng-template, so When i inject TemplateRef inside this directive, does it refer to the ng-template on which this directive gets applied ?

that’s easy to check, right? you just put a debugger inside the constructor and inspect the variable

again, easy to check by inspecting the variable, but yes, you’re right


can you please update this article for angular 10

Hi @brandd,

@Manoj recently published a similar article that is up-to-date on best practices in modern versions of Angular:

Discussion topic: