NG8113 Angular Origin: On your device Angular 19+ Last updated 15 Oct 2026

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

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

Exact message you may see is not used within the template ofunused standalone importsNgIf is not used within the templateNgFor is not used within the template
Seen on: Angular TypeScript

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+?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

NG02200 — Angular: NG02200: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays (Angular)NG02200NG0301 — Angular: NG0301: Export of name 'x' not found! (template variable #x="exportAs") (Angular)NG0301NG6008 — Angular: NG6008: Component X is standalone, and cannot be declared in an NgModule. Did you mean to import it instead? (Angular)NG6008NG8001 — Angular: NG8001: 'app-item' is not a known element — verify that it is included in the component's imports (Angular)NG8001NG8002 — Angular: NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input' (Angular)NG8002NG8003 — Angular: NG8003: No directive found with exportAs 'ngForm' (template reference variable) (Angular)NG8003NG8103 — Angular: NG8103: The *ngIf directive was used, but neither the NgIf directive nor the CommonModule was imported (Angular)NG8103NG8113

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.