Open Aliaksandr-Padabed opened 6 years ago
@Aliaksandr-Padabed Agreed with you. I encounter the exact same situation with a shared filter and a shared service. For example, let's say I have a custom loggerService
that I would like to use accross different components. The styleguide does not mention where to put it.
The styleguide considers an AngularJS application as a cluster of isolated components which can communicate with each other. But, it feels like it's missing a part about the application wide shared code .
Anyway, I ended up attaching my service and my filter to the app.components
module like this:
export default angular
.module('app.components', [
ProjectModule,
LearnModule,
])
.filter('mySharedFilter', SharedFilter)
.service('mySharedService', SharedService)
.name;
For example I have two components which use same filter. It is not clear from the styleguide should I duplicate filter code in each module, or move filter to parent/root module? Or create something like common.module to keep reusable code? From performance point of view keeping filters as separate files in common folder (not in common module) is better because filter will not be included in every bundle.