0

I created a basic Angular project in VS Code, but the app.module.ts file was missing, so I manually created it and added @NgModule. I then generated a new component named user and imported this user component in app.module.ts, but I got an error.

However, when I imported the user component in app.component.ts, it worked. It seems like app.module.ts is not being compiled properly. Additionally, I am getting an error saying NgModule is not declared. How can I resolve this issue?

Errors:

X [ERROR] NG8001: 'app-use' is not a known element:

  1. If 'app-use' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
  2. If 'app-use' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message. [plugin angular-compiler]

X [ERROR] NG8003: No directive found with exportAs 'ngForm'. [plugin angular-compiler]

I expected the app.module.ts file to compile correctly and recognize @NgModule and other Angular decorators.

I expected the user component to be successfully declared in app.module.ts without any issues.

4
  • 1
    You don't need AppModule anymore. Commented Jan 17 at 18:35
  • Firstly, Thanks for your response! "But the error arises because I used #useForm="ngForm" in my user.html page. The NgModule is necessary and it is imported in app.module.ts" Commented Jan 17 at 19:05
  • Please provide enough code so others can better understand or reproduce the problem. Commented Jan 17 at 21:28
  • 1
    Just import directly FormsModule directely in your standalone component. Commented Jan 17 at 23:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.