Setup a store
To create a store, you need to import and use the NgStore
class. NgStore
accepts a single parameter as the initial state of your store.
import NgStore from 'angularjs-store';
const initialState = { count: 0 };
const counterStore = new NgStore(initialState);
Then, to make the store injectable in your AngularJS application, you need to attach it to AngularJS service.
import NgStore from 'angularjs-store';
function counterStore() {
const initialState = { count: 0 };
const counterStore = new NgStore(initialState);
return counterStore;
}
angular
.module('app', [])
.service('counterStore', counterStore);
Last updated
Was this helpful?