Skip to content

Better error message for misplaced NgSwitchDefault #41591

Closed
@jrsun

Description

@jrsun

🐞 bug report

Affected Package

The issue is caused by package @angular/common.

Is this a regression?

No.

Description

This is a request for clearer error messaging. When an NgSwitchDefault directive erroneously exists outside of a NgSwitch, the error message appears to be import-related, rather than a syntax error: No provider for NgSwitch found in NodeInjector...

🔬 Minimal Reproduction

  1. https://stackblitz.com/edit/angular-ivy-zexnwp?file=src/app/app.component.ts
  2. See console for error.

🔥 Exception or Error




ERROR Error: NG0201: No provider for NgSwitch found in NodeInjector

🌍 Your Environment

Angular Version:




any

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: commonIssues related to APIs in the @angular/common packagegood first issueAn issue that is suitable for first-time contributors; often a documentation issue.help wantedAn issue that is suitable for a community contributor (based on its complexity/scope).hotlist: error messages

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions