Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!