Skip to content

Commit 89c3f82

Browse files
committed
Update README.md
1 parent 86de39a commit 89c3f82

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ import * as CounterActions from '../actions/counter';
5151

5252
class 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
92105
All 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

98114
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

Comments
 (0)