@@ -51,6 +51,9 @@ import * as CounterActions from '../actions/counter';
51
51
52
52
class CounterController {
53
53
constructor ($ngRedux , $scope ) {
54
+ /* ngRedux will merge the requested state's slice and actions onto the $scope,
55
+ you don't need to redefine them in your controller */
56
+
54
57
$ngRedux .connect ($scope, this .mapStateToScope , CounterActions, ' vm' );
55
58
}
56
59
@@ -63,6 +66,16 @@ class CounterController {
63
66
}
64
67
```
65
68
69
+ ``` HTML
70
+ <div >
71
+ <p >Clicked: {{vm.counter}} times </p >
72
+ <button ng-click =' vm.increment()' >+</button >
73
+ <button ng-click =' vm.decrement()' >-</button >
74
+ <button ng-click =' vm.incrementIfOdd()' >Increment if odd</button >
75
+ <button ng-click =' vm.incrementAsync()' >Increment Async</button >
76
+ </div >
77
+ ```
78
+
66
79
## API
67
80
68
81
### ` createStoreWith([reducer], [middlewares], [storeEnhancers]) `
@@ -92,7 +105,10 @@ As `$scope` is passed to `connect`, ngRedux will listen to the `$destroy` event
92
105
All of redux's store methods (i.e. ` dispatch ` , ` subscribe ` and ` getState ` ) are exposed by $ngRedux and can be accessed directly. For example:
93
106
94
107
``` JS
95
- redux .bindActionCreators (actionCreator, $ngRedux .dispatch );
108
+ $ngRedux .subscribe (() => {
109
+ let state = $ngRedux .getState ();
110
+ // ...
111
+ })
96
112
```
97
113
98
114
This means that you are free to use Redux basic API in advanced cases where ` connect ` 's API would not fill your needs.
0 commit comments