@@ -51,6 +51,9 @@ import * as CounterActions from '../actions/counter';
5151
5252class CounterController {
5353 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+
5457 $ngRedux .connect ($scope, this .mapStateToScope , CounterActions, ' vm' );
5558 }
5659
@@ -63,6 +66,16 @@ class CounterController {
6366}
6467```
6568
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+
6679## API
6780
6881### ` createStoreWith([reducer], [middlewares], [storeEnhancers]) `
@@ -92,7 +105,10 @@ As `$scope` is passed to `connect`, ngRedux will listen to the `$destroy` event
92105All of redux's store methods (i.e. ` dispatch ` , ` subscribe ` and ` getState ` ) are exposed by $ngRedux and can be accessed directly. For example:
93106
94107``` JS
95- redux .bindActionCreators (actionCreator, $ngRedux .dispatch );
108+ $ngRedux .subscribe (() => {
109+ let state = $ngRedux .getState ();
110+ // ...
111+ })
96112```
97113
98114This 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