22
33## Introduction
44
5- This style guide addresses four areas: High-level Goals; Directory and File Structure; Parts of Angular; and General Patterns and Anti-patterns.
6-
7- High-level Goals are those that guide low-level decision making.
8-
9- Directory and File Structure addresses the way we organise our code and why.
10-
11- Parts of Angular addresses the core parts of AngularJS — routes, directives, controllers, modules, and templates.
12-
13- General Patterns and Anti-patterns addresses those that do not pertain to a specific part, but instead to the application at large.
5+ This is the style guide we use for AngularJS internally at GoCardless.
146
157## Table of Contents
1681 . [ High-level Goals] ( #high-level-goals )
@@ -20,6 +12,8 @@ General Patterns and Anti-patterns addresses those that do not pertain to a spec
2012
2113## High-level Goals
2214
15+ The principles we use to guide low-level decision making are:
16+
23171 . Prioritise readability.
24182 . Be explicit, not implicit.
25193 . Favour composability over inheritance.
@@ -28,6 +22,8 @@ General Patterns and Anti-patterns addresses those that do not pertain to a spec
2822
2923## Directory and File Structure
3024
25+ We organise our code as follows:
26+
3127### Folder structure
3228
3329```
@@ -99,6 +95,8 @@ Services contain Business logic. For example, `$http` abstractions.
9995
10096## Parts of Angular
10197
98+ Rules for using each of the core parts of AngularJS (routes, directives, controllers, modules, and templates).
99+
102100### Routes
103101
104102#### Use resolvers to inject data.
@@ -314,7 +312,7 @@ angular.module('AdminExpandComponentModule', [])
314312 }
315313
316314 $window .document .addEventListener (' click' , expand);
317-
315+
318316 scope .$on (' $destroy' , function onAdminExpandDestroy () {
319317 $window .document .removeEventListener (' click' , expand);
320318 });
@@ -483,7 +481,7 @@ angular.module('OrganisationRolesNewControllerModule', [])
483481 var ctrl = this ;
484482
485483 ctrl .permissions = permissions;
486-
484+
487485 ctrl .setAllPermissions = function setAllPermissions (access ) {
488486 ctrl .form .permissions .forEach (function (permission ) {
489487 permission .access = access;
@@ -727,11 +725,13 @@ _Why_: Avoids unnecessary expensive `$watch`ers.
727725#### Anti-Patterns
728726
729727- Don’t use ` ngInit ` – use controllers instead.
730- - Don’t use ` <div ng-controller="Controller"> ` syntax. Use directives instead.
728+ - Don’t use ` <div ng-controller="Controller"> ` syntax. Use directives instead.
731729
732730
733731## General Patterns and Anti-Patterns
734732
733+ Rules that pertain to our application at large, not a specific part of Angular.
734+
735735### Patterns
736736
737737#### Angular abstractions
0 commit comments