# Custom Structural Directive

Your own directive that adds or removes template blocks.

## What is **Custom Structural Directive**?

A **custom structural directive** adds or removes parts of the template, like your own `@if`. It uses `TemplateRef` and `ViewContainerRef`.

```typescript
@Directive({ selector: '[appIfAdmin]' })
export class IfAdmin {
  constructor() {
    if (inject(AuthService).isAdmin())
      inject(ViewContainerRef).createEmbeddedView(inject(TemplateRef));
  }
}
```

Level: Master · [More Angular terms at this level](https://www.ask-codey.com/glossary?category=angular&level=5)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/custom-structural-directive
