In my particular case, I am utilizing an AngularJS application, although I believe this inquiry is relevant to any Single Page App.
I've implemented a component structure as outlined in various resources such as this and this.
Let's assume I have a setup similar to the one demonstrated in John Papa's example:
app/
app.module.js
app.config.js
app.routes.js
directives.js
layout/
shell.html
shell.controller.js
topnav.html
topnav.controller.js
people/
attendees.html
attendees.controller.js
speakers.html
speakers.controller.js
speaker-detail.html
speaker-detail.controller.js
sessions/
sessions.html
sessions.controller.js
session-detail.html
session-detail.controller.js
services/
data.service.js
localstorage.service.js
logger.service.js
spinner.service.js
Here are some questions regarding the most effective approach (based on your experience) to follow this practice, potential pitfalls to watch out for, and strategies to prevent future issues with the directory structure: considering that we are dealing with a large-scale application that will continue to expand over time.
If
spinner.service.js
is only utilized within thelayout
controllers, should it be placed in the/layout
directory? Or should all services always be housed in a generic folder?For instance, if I want to employ
/people/speakers
simultaneously as a partial within another page like/admin/speakers
, how should I handle this scenario? Should I consider makingspeakers
a standalone component at the same level as/people
and/admin
?To pose a more broad question: in cases where both a
detail view
and alist view
of an item are required, would it be preferable to consolidate everything inside the/item
directory (as illustrated in this instance)?