Skip to content

Commit 0e561d7

Browse files
committed
Update readme
1 parent 35cec84 commit 0e561d7

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* [Directives](#directives)
1515
* [Filters](#filters)
1616
* [Services](#services)
17-
* [Angular 2 overview](#angular-2-overview)
17+
* [Angular 2 Overview](#angular-2-overview)
1818
* [Components](#components)
1919
* [Services](#services)
2020
* [Dependency Injection](#dependency-injection)
@@ -270,13 +270,15 @@ function MyCtrl(Developer) {
270270
}
271271
```
272272

273+
## Angular 2 Overview
274+
273275
## AngularJS in Patterns
274276

275-
In the next a couple of sections, we are going to take a look how the traditional design and architectural patterns are composed in the AngularJS components.
277+
In the next a couple of sections, we are going to take a look at how the traditional design and architectural patterns are composed in the AngularJS components. The following chapter is devided in two parts - AngularJS 1.x and Angular 2. In the corresponding chapters the patterns will be put in the appropriate context.
276278

277-
In the last chapter we are going to take a look at some architectural patterns, which are frequently used in the development of Single-Page Applications with (but not limited to) AngularJS.
279+
### AngularJS 1.x
278280

279-
### Services
281+
#### Services
280282

281283
<!-- include singleton -->
282284

@@ -324,7 +326,7 @@ This way the services are actually singletons but not implemented through the Si
324326

325327
For further discussion on this topic Misko Hevery's [article](http://googletesting.blogspot.com/2008/05/tott-using-dependancy-injection-to.html) in the Google Testing blog could be considered.
326328

327-
#### Factory Method
329+
##### Factory Method
328330

329331
<!-- include factory-method -->
330332

@@ -412,7 +414,7 @@ There are a few benefits of using the factory method pattern in this case, becau
412414
- Resolving all the dependencies required by the component
413415
- The number of instances the given component is allowed to have (for services and filters only a single one but multiple for the controllers)
414416

415-
#### Decorator
417+
##### Decorator
416418

417419
<!-- include decorator -->
418420

@@ -450,7 +452,7 @@ We decorate the service by overriding its method `bar`. The actual decoration is
450452

451453
Using this pattern is especially useful when we need to modify the functionality of third party services. In cases when multiple similar decorations are required (like performance measurement of multiple methods, authorization, logging, etc.), we may have a lot of duplications and violate the DRY principle. In such cases it is useful to use [aspect-oriented programming](http://en.wikipedia.org/wiki/Aspect-oriented_programming). The only AOP framework for AngularJS I'm aware of could be found at [github.com/mgechev/angular-aop](https://github.com/mgechev/angular-aop).
452454

453-
#### Facade
455+
##### Facade
454456

455457
<!-- include facade -->
456458

@@ -499,7 +501,7 @@ The second option provides pre-configured version, which creates a HTTP POST req
499501

500502
Even higher level of abstraction is being created by `$resource`, which is build over the `$http` service. We will take a further look at this service in [Active Record](#active-record) and [Proxy](#proxy) sections.
501503

502-
#### Proxy
504+
##### Proxy
503505

504506
<!-- include proxy -->
505507

@@ -535,7 +537,7 @@ function MainCtrl($scope, $resource) {
535537
```
536538
Initially when the snippet above executes, the property `user` of the `$scope` object will be with value an empty object (`{}`), which means that `user.name` will be undefined and nothing will be rendered. Internally AngularJS will keep reference to this empty object. Once the server returns response for the get request, AngularJS will populate the object with the data, received from the server. During the next `$digest` loop AngularJS will detect change in `$scope.user`, which will lead to update of the view.
537539

538-
#### Active Record
540+
##### Active Record
539541

540542
<!-- include active-record -->
541543

@@ -576,7 +578,7 @@ Since Martin Fowler states that
576578
577579
`$resource` does not implements exactly the Active Record pattern, since it communicates with RESTful service instead of the database. Anyway, we can consider it as "Active Record like RESTful communication".
578580

579-
#### Intercepting Filters
581+
##### Intercepting Filters
580582

581583
<!-- include intercepting-filters -->
582584

@@ -601,9 +603,9 @@ $httpProvider.interceptors.push(function($q, dependency1, dependency2) {
601603
});
602604
```
603605

604-
### Directives
606+
#### Directives
605607

606-
#### Composite
608+
##### Composite
607609

608610
<!-- include composite -->
609611

@@ -650,7 +652,7 @@ From the first example we can note that the whole DOM tree is a composition of e
650652

651653
In the second, JavaScript, example we see that the `template` property of the directive, contains markup with `ng-transclude` directive inside it. So this means that inside the directive `zippy` we have another directive called `ng-transclude`, i.e. composition of directives. Theoretically we can nest the components infinitely until we reach a leaf node.
652654

653-
### Interpreter
655+
#### Interpreter
654656

655657
<!-- include interpreter -->
656658

@@ -718,7 +720,7 @@ Few sample AngularJS expressions are:
718720
(foo) ? bar : baz | toUpperCase
719721
```
720722

721-
#### Template View
723+
##### Template View
722724

723725
<!-- include template-view -->
724726

@@ -771,9 +773,9 @@ $scope.names = ['foo', 'bar', 'baz'];
771773
will produce the same result as the one above. The main difference here is that the template is not wrapped inside a `script` tag but is HTML instead.
772774

773775

774-
### Scope
776+
#### Scope
775777

776-
#### Observer
778+
##### Observer
777779

778780
<!-- pattern observer -->
779781

@@ -807,7 +809,7 @@ Each scope can subscribe to any event with multiple callbacks (i.e. it can assoc
807809

808810
In the JavaScript community this pattern is better known as publish/subscribe.
809811

810-
#### Chain of Responsibilities
812+
##### Chain of Responsibilities
811813

812814
<!-- include chain-of-responsibilities -->
813815

@@ -842,7 +844,7 @@ myModule.controller('ChildCtrl', function ($scope) {
842844

843845
The different handlers from the UML diagram above are the different scopes, injected to the controllers.
844846

845-
#### Command
847+
##### Command
846848

847849
<!-- include command -->
848850

@@ -883,9 +885,9 @@ $watch: function(watchExp, listener, objectEquality) {
883885
884886
We can think of the `watcher` object as a command. The expression of the command is being evaluated on each [`"$digest"`](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) loop. Once AngularJS detects change in the expression, it invokes the `listener` function. The `watcher` command encapsulates the whole information required for watching given expression and delegates the execution of the command to the `listener` (the actual receiver). We can think of the `$scope` as the command's `Client` and the `$digest` loop as the command's `Invoker`.
885887
886-
### Controllers
888+
#### Controllers
887889
888-
#### Page Controller
890+
##### Page Controller
889891
890892
<!-- include page-controller -->
891893
@@ -933,9 +935,9 @@ This example aims to illustrates the most trivial way to reuse logic by using a
933935
934936
The `ChildCtrl` is responsible for handling actions such as clicking the button with label `"Click"` and exposing the model to the view, by attaching it to the scope.
935937
936-
### Others
938+
#### Others
937939
938-
#### Module Pattern
940+
##### Module Pattern
939941
940942
<!-- include module-pattern -->
941943
@@ -962,7 +964,7 @@ app.factory('foo', function () {
962964
963965
Once we want to inject `foo` inside any other component we won't be able to use the private methods, but only the public ones. This solution is extremely powerful especially when one is building a reusable library.
964966
965-
### Data Mapper
967+
#### Data Mapper
966968
967969
<!-- include data-mapper -->
968970

0 commit comments

Comments
 (0)