AngularJS Store
v4.0.5
v4.0.5
  • Introduction
  • What's New
  • Installation
  • Tutorials with Javascript
    • Setup a store
    • Get the current state
    • Update the state
    • Listen on state changes
    • Destroy a hook
  • Tutorials with Typescript
    • Setup a store
    • Get the current state
    • Update the state
    • Listen on state changes
    • Destroy a hook
Powered by GitBook
On this page

Was this helpful?

  1. Tutorials with Typescript

Get the current state

After creating a store, you can now consume it into your application. To get the current state, you need to use the copy method of the store.

your-controller.ts
import { CounterStore } from 'counter-store';

function YourController($scope: ng.IScope, counterStore: CounterStore) {
  const counterState = counterStore.copy();
  $scope.count = counterState.count;
}

angular
  .module('App', [])
  .controller('YourController', YourController);

copy always returns a new copy of the state. Any direct changes in the state copy will not affect the original state of the store.

PreviousSetup a storeNextUpdate the state

Last updated 5 years ago

Was this helpful?