Search⌘ K
AI Features

Creating a Structural Directive

Understand how to build a custom structural directive in Angular that replicates the functionality of ngFor. Learn to use ViewContainerRef and TemplateRef to dynamically insert elements, accept input data for looping, and update templates to work with the directive for flexible DOM manipulation.

We’ll be creating another directive that will replace the ngFor directive. The last directive we created was an attribute directive. The ngFor directive is a structural directive because it adds/removes elements from the ...