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

StateKey

A type-safe key to use with TransferState.

See more...

type StateKey<T> = string & { __not_a_string: never; };
      
      type StateKey<T> = string & {
    __not_a_string: never;
};
    

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);