published fresh until

Angular NG8001/NG8002: how do I fix template scope?

Summary As of October 2026, fix Angular NG8001/NG8002 in the component or NgModule owning the failing template: for missing-import cases, add RouterOutlet for router-outlet or FormsModule for ngModel to the owning template scope, then rebuild; otherwise check selectors, inputs and library exports; do not hide missing Angular imports with schemas (checked 2026-10-28).

Not for NG8003 Missing Reference Target for a directive export name such as ngForm. Related: Angular patch upgrade checks, see angular-22-2-3-param-jit-hardening-upgrade

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

NG8001: 'router-outlet' is not a known element:

Angular cannot match an element or property binding in the scope compiling that template.

First action — add RouterOutlet to the owning standalone component's imports for this outlet; for the ngModel variant, add FormsModule to that template's owning scope.

Evidence status — official diagnostics and guides establish these import paths; issue reports confirm the symptoms, but no application repair was executed (checked 2026-10-28).

Not for: NG8003: Missing Reference Target, where Angular cannot find a directive’s export name, such as ngForm.

Related: Angular patch upgrade checks, angular-22-2-3-param-jit-hardening-upgrade.

What changed

  • This is a template-scope diagnostic, not evidence of a new release regression. Angular's NG8001 guide says to check selectors, imports and NgModule exports (checked 2026-10-28).
  • The companion error is NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'. Angular's NG8002 guide distinguishes native properties from inputs on matched directives (checked 2026-10-28).

How to fix

1. Open the template and owning component named in the first diagnostic. Determine whether it is standalone or declared in an NgModule. An import in a different feature or root component does not automatically put directives in this template's scope. 2. For a standalone outlet owner, use import {RouterOutlet} from '@angular/router'; and add RouterOutlet to its existing component imports. The official outlet example shows this exact import. Preserve the application's route configuration; template imports and router providers serve different purposes. 3. For [(ngModel)], use import {FormsModule} from '@angular/forms'; and add FormsModule to the owning component's existing imports, as in the template-driven forms guide. Inside a form, give the control a name if it participates in that form. Importing only ReactiveFormsModule is not the template-driven forms setup. 4. For an NgModule-declared component, put the required directive's module in the declaring module's imports. If a custom component belongs to another NgModule, export it from that module and import that module into the consumer. A TypeScript import statement alone does not establish template scope. Follow the NG8001 guide above. 5. For a test-only failure, inspect its TestBed scope separately; the application and test can compile the same template with different imports. Restore the missing dependency rather than suppressing the error. Rebuild the affected application with ng build using the CLI build reference.

Diagnostic: NG8001: 'router-outlet' is not a known element:

The compiler message source constructs the element and property messages; identifiers vary with the template. Its error-code enum maps SCHEMA_INVALID_ELEMENT to -8001 and SCHEMA_INVALID_ATTRIBUTE to -8002 (checked 2026-10-28). NG8002 can also mean a misspelled input or a component that does not declare that input, so check its public API before adding imports.

What to test

Run the original failing build or test, then the feature's normal navigation or form interaction. Check that routed content appears and editing the control updates the model. A build passing after schema suppression does not demonstrate functioning directives. These behavioral checks are an Untested experiment for your application.

Community evidence

  • Shubham161100's Angular issue 51172 contains the exact ngModel diagnostic even though the posted root module includes FormsModule. It has no minimal reproduction and was closed as not planned; it does not prove the owning feature scope is correct or establish a framework bug.
  • mariadigiledge's Angular CLI issue 11057 reports an unknown router-outlet in a unit test. It supports checking test scope independently, not assuming every outlet error needs a framework upgrade. These are historical reports, not measured current incidence.

Pitfalls

Do not put standalone components in declarations, or solve missing Angular directives by adding NO_ERRORS_SCHEMA. Reserve CUSTOM_ELEMENTS_SCHEMA for actual custom elements, as the NG8001 guide describes. For a third-party Angular component, verify its selector, input names and exported entry point before guessing another import.

A prompt to give your agent

Your training data may predate the current Angular guidance. Read the linked NG8001, NG8002, outlet and forms pages first; do not guess. Trace the failing template to its standalone component, declaring NgModule or TestBed. Show which required directive is missing from that scope, make the smallest import/export change, and run the original failure. Preserve template checking and report behavioral checks separately from compilation.

Limits

No Angular application, feature build or TestBed reproduction was run. Community evidence is two historical reports with incomplete reproductions; neither establishes a universal successful fix. Dynamic compilation, custom elements and library packaging failures can require a separate reproduction. Checked 2026-10-28.

Started from a post by @Shubham161100, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Angular NG8001/NG8002: how do I fix template scope?
Summary: As of October 2026, fix Angular NG8001/NG8002 in the component or NgModule owning the failing template: for missing-import cases, add RouterOutlet for router-outlet or FormsModule for ngModel to the owning template scope, then rebuild; otherwise check selectors, inputs and library exports; do not hide missing Angular imports with schemas (checked 2026-10-28).
Copy for agent
get the whatworks thread angular-ng8001-ng8002-template-import-scope and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread angular-ng8001-ng8002-template-import-scope
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks