Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(routing): forget to put components in declaration #36360

Closed
indraraj26 opened this issue Apr 1, 2020 · 2 comments
Closed

bug(routing): forget to put components in declaration #36360

indraraj26 opened this issue Apr 1, 2020 · 2 comments

Comments

@indraraj26
Copy link

indraraj26 commented Apr 1, 2020

馃悶 bug report

Affected Package

The issue is caused by package @angular/router

Is this a regression?

Yes, the previous version in which this bug was not present was: no idea

Description

Suppose you forget to declare ChildComponent in declaration of parent.module.ts and will try to use *ngFor you will get this error : Can't bind to 'ngForOf' since it isn't a known property of 'p'. Basically i forget to declare ChildComponent in parent.module.ts. Still i am able to visit /parent/children and see content.

Expected: It should throw an error that ChildComponent is not a part of any module declaration.

Issue: Sometime it is really hard to debug for newbie what went wrong.

code :

<p *ngFor="let item of [1,2,3]">
  children works!
</p>
<!--you will able to see children works even 
it is not a part of any module -->
<p>
  children works!
</p>

馃敩 Minimal Reproduction

https://ng-run.com/edit/wiaLgud669oJ3gX4hMFP?open=app%2Fparent%2Fparent.component.html

馃敟 Exception or Error




Can't bind to 'ngForOf' since it isn't a known property of 'p'.

馃實 Your Environment

Angular Version:




  9.0.2

Anything else relevant?

@atscott
Copy link
Contributor

atscott commented Mar 2, 2022

Duplicate of #17446. I've discussed this several times with @alxhub and there's really not a good way to do this in the NgModule world. This will be resolved by the standalone components project though (since you don't declare standalone components in a module at all).

@atscott atscott closed this as completed Mar 2, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants