# Angular: NG8113: NgIf is not used within the template of AppComponent — unused standalone import

**Code:** `NG8113` · **Category:** Angular · **Seen on:** Angular, TypeScript

A standalone component lists a directive, pipe or component in `imports` but never uses it in its template.

## Meaning

The compiler warns (Angular 19+) so bundles do not carry dead code. After moving to `@if` / `@for`, the old `NgIf` / `NgFor` imports become unused. Remove the import, or if you really need it only in TypeScript, do not list it in `imports`.

## Common causes

- Migrated to `@if` / `@for` and left `NgIf` / `NgFor` in `imports`
- Component or pipe removed from the template but still imported
- Copy-pasted `imports` array from another component
- Directive used only in a different component's template

## Quick fix

1. Delete the unused item from the `imports` array
2. Run the cleanup schematic
3. Keep the warning as an error in CI to prevent drift

## Detailed fix by platform

### Angular CLI

1. `ng generate @angular/core:cleanup-unused-imports` removes them automatically (Angular 19+)

## Code examples

### Trim imports

```typescript
@Component({
  selector: 'app-list',
  standalone: true,
  // imports: [NgIf, NgFor, JsonPipe],   // NG8113 for each one the template no longer uses
  imports: [JsonPipe],
  template: `@for (i of items; track i.id) { <pre>{{ i | json }}</pre> }`,
})
export class ListComponent { items = [{ id: 1 }]; }
```

## How to diagnose

1. **Template** — Is the item referenced anywhere in the template?
2. **Migration** — Did you move to @if / @for?
3. **Version** — Angular 19+?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng8113-unused-standalone-import)
