Update the state
angular
.module('App', [])
.controller('ControllerB', function ControllerB(CounterStore) {
let currentCount;
currentCount = CounterStore.copy('count');
CounterStore.dispatch('INCREMENT_COUNT', {
count: currentCount + 1;
});
currentCount = CounterStore.copy('count');
CounterStore.dispatch('DECREMENT_COUNT', {
count: currentCount - 1;
});
});angular
.module('App', [])
.controller('ControllerB', function ControllerB(CounterStore) {
CounterStore.dispatch('INCREMENT_COUNT', function (state) {
return { count: state.count + 1 };
});
CounterStore.dispatch('DECREMENT_COUNT', function (state) {
return { count: state.count - 1 };
});
});Last updated
Was this helpful?