Reference
injectStore
Atom<TState> | ReadonlyAtom<TState>
The store atom to subscribe to.
(state: TState) => TSelected
default:"(d) => d"
Optional function that selects a slice of state from the atom. Defaults to returning the entire state.
CreateSignalOptions<TSelected> & { injector?: Injector }
Optional configuration object.
Returns
Signal<TSelected>
An Angular readonly signal containing the selected state value.
Usage
Basic Usage
Selecting Multiple Values
Custom Equality Function
Using Entire State
With Computed Signals
With Custom Injector
Control Flow with @if
With @for Loop
Notes
- Must be called within an injection context (constructor, field initializer) or provide a custom injector
- Returns an Angular readonly signal - access the value by calling it as a function
- Uses
linkedSignalinternally for optimal Angular reactivity - Automatically cleans up subscriptions using
DestroyRef - Defaults to
shallowequality comparison - Compatible with Angular’s signals and computed values
- Works seamlessly with Angular’s control flow syntax (@if, @for, etc.)