How many component files should I have in Angular 2?

59 views
Skip to first unread message

Dustin B

unread,
Mar 18, 2016, 4:58:21 PM3/18/16
to AngularJS
I'm looking for some advice on how much splitting up of components I should be doing.

I have made my Angular 2 app very modular, with various components and services.  I have generally divided these components into different .ts/.js files, based on how much that have to do with one another. The result is a handful of large .ts/.js files that contain several Components in each file.

So, my question: can I split them more? Should each component be its own file? Does dependency injection manage this efficiently?  If I break up components more granularly, will it hurt performance? 

I'm basically wondering what others are doing, and is there a best practice? 

Thanks!

Dustin B

unread,
Mar 21, 2016, 4:04:04 PM3/21/16
to AngularJS
Anyone have any thoughts on this? I'd love some advice/opinions.

Thanks,
Dustin

Sander Elias

unread,
Mar 22, 2016, 12:27:46 AM3/22/16
to AngularJS
Hi Dustin,

The advice is to have every component/service in it's own file. When you use proper build tools, this will not hurt performance (the build tools will make a single file out of it!)

Regards
Sander 

Dustin Buss

unread,
Mar 22, 2016, 12:43:33 AM3/22/16
to ang...@googlegroups.com
Thanks! 

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/CaCxO3dYVMU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages