Exists Angularjs code/naming conventions? [closed]
Does anyone know if exists any official or most accepted reference for Angular naming conventions to use when we build our applications?
Angular has many different types of components such as filters, directives, services, and so on.
Wouldn't you agree that having a reference naming convention when we implement them in our applications will make sense?
For example: If we need to create new filters, how should we name them like [Something]Filter or filter[Something] or something else? And same applies to Controllers, Services, Directives, and so on. I wonder if variables/functions that belong to the scope should have a particular prefix or suffix. In some situations, it may be useful to have a way to differentiate them from functions and other (none angular code).
Check out this GitHub repository that describes best practices for AngularJS apps. It has naming conventions for different components. It is not complete, but it is community-driven so everyone can contribute.
If you are a beginner, it is better you first go through some basic tutorials and after that learn about naming conventions. I have gone through the following to learn Angular, some of which are very effective.
Tutorials :
- http://www.toptal.com/angular-js/a-step-by-step-guide-to-your-first-angularjs-app
- http://viralpatel.net/blogs/angularjs-controller-tutorial/
- http://www.angularjstutorial.com/
Details of application structure and naming conventions can be found in a variety of places. I've gone through 100's of sites and I think these are among the best:
- https://github.com/camronlevanger/AngularJS-Guide
- https://github.com/mgechev/angularjs-style-guide
- https://google.github.io/styleguide/angularjs-google-style.html
For structuring an app, this is one of the best guides that I've found:
- Google's Best Practice Recommendations for Angular App Structure
Note that the structure recommended by Google is different than what you'll find in a lot of seed projects, but for large apps it's a lot saner.
Google also has a style guide that makes sense to use only if you also use Closure.
...this answer is incomplete, but I hope that the limited information above will be helpful to someone.