Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AngularJS Basics (1.x) Getting Started with Angular Your First Angular Directive

A new file for every custom directive?

Do you have to create a new JS file for every custom directive? It wasn't clear in the video.

Thanks in advance!

1 Answer

Partitioning code into multiple files is a style choice. You don't have to, but if your code is long, then it might be a good idea to create a new file to make it easier to maintain. Too many files vs long code in a single file... it's a decision you would have to make.

Personally, I would prefer a new file (except if it's a one-liner). It's just easier to read in a separate file than inside quotes.

Ok gotcha, thanks!