This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

makeStateKey

Create a StateKey<T> that can be used to store value of type T with TransferState.

See more...

makeStateKey<T = void>(key: string): StateKey<T>
      
      makeStateKey<T = void>(key: string): StateKey<T>
    

Parameters

key

Type: string.

Returns

StateKey<T>

Description

Example:

const COUNTER_KEY = makeStateKey<number>('counter'); let value = 10; transferState.set(COUNTER_KEY, value);
      
      const COUNTER_KEY = makeStateKey<number>('counter');
let value = 10;

transferState.set(COUNTER_KEY, value);