Adding an import to app.module.ts throws an error

26 views
Skip to first unread message

Maureen Moore

unread,
Jun 28, 2020, 4:47:11 PM6/28/20
to Angular and AngularJS discussion
I thought that if you add an import to the controller.ts file, that it had to be added to app.module.ts as well. But, when I added the NgForm to my controller alone without adding it to app.module.ts my code worked fine. Then when I added it to app.module.ts I got an error. What is the right way to do it?

maninder singh Kumar

unread,
Jun 28, 2020, 6:51:05 PM6/28/20
to ang...@googlegroups.com
If your controller.ts is part of a module that is added in app.module.ts then it doesn't need to have that import.
I think you worked it out !

regards .... willy


On Mon, Jun 29, 2020 at 2:17 AM Maureen Moore <maka...@gmail.com> wrote:
I thought that if you add an import to the controller.ts file, that it had to be added to app.module.ts as well. But, when I added the NgForm to my controller alone without adding it to app.module.ts my code worked fine. Then when I added it to app.module.ts I got an error. What is the right way to do it?

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/635c3250-2778-46ed-aa72-1d441908ddefo%40googlegroups.com.

Maureen Moore

unread,
Jun 28, 2020, 7:06:52 PM6/28/20
to Angular and AngularJS discussion
Thanks, Willy

On Sunday, June 28, 2020 at 6:51:05 PM UTC-4, maninder singh Kumar wrote:
If your controller.ts is part of a module that is added in app.module.ts then it doesn't need to have that import.
I think you worked it out !

regards .... willy


On Mon, Jun 29, 2020 at 2:17 AM Maureen Moore <maka...@gmail.com> wrote:
I thought that if you add an import to the controller.ts file, that it had to be added to app.module.ts as well. But, when I added the NgForm to my controller alone without adding it to app.module.ts my code worked fine. Then when I added it to app.module.ts I got an error. What is the right way to do it?

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.

maninder singh Kumar

unread,
Jun 28, 2020, 7:14:19 PM6/28/20
to ang...@googlegroups.com
The email was for an angular developer with 2 years experience.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/88e879d2-9bb2-4902-a31b-09744b7e4203o%40googlegroups.com.

Sander Elias

unread,
Jun 28, 2020, 11:42:35 PM6/28/20
to Angular and AngularJS discussion
Hi Maureen,

No, you don't need to add imports in your controllers to your modules. Typescript and the build tools take care of this. (to be complete, the underlying JS could be taking care too, but that's not a consideration right now)

Regards
Sander

Maureen Moore

unread,
Jun 29, 2020, 7:46:05 AM6/29/20
to Angular and AngularJS discussion
Thanks, Sander. I don't know how to post a reply without all of the preceding posts attached.

Sander Elias

unread,
Jun 29, 2020, 11:57:37 AM6/29/20
to Angular and AngularJS discussion
Use <ctrl-a> and then <del>  

Regards
Sander
Reply all
Reply to author
Forward
0 new messages