Structural directives, composition and injection
Learn Structural directives, composition and injection (Module 6 · Directives, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Creating custom structural directives • A custom structural directive decides whether to show a piece of template. It receives a TemplateRef (the blueprint) and a ViewContainerRef (the place to draw). Example: *appHasRole="'ADMIN'" shows content only for admins (a UI convenience; the backend still enforces permissions).