Store Docs
API Reference
Store API Reference
- Store
- ReadonlyStore
- Atom
- AtomOptions
- BaseAtom
- InternalBaseAtom
- InternalReadonlyAtom
- InteropSubscribable
- Readable
- ReadonlyAtom
- StoreActionsApi
- Subscribable
- Subscription
- AnyAtom
- Observer
- Selection
- StoreAction
- StoreActionMap
- StoreActionsFactory
- batch
- createAsyncAtom
- createAtom
- createStore
- flush
- shallow
- toObserver
- injectSelector
- injectSetValue
- injectAtom
- injectStoreActions
- injectStore (deprecated)
- InjectSelectorOptions
AI/LLM: This documentation page is available in plain markdown format at/store/latest/docs/framework/angular/reference/functions/injectAtom.md
Store API Reference
injectAtom
ts
function injectAtom<TValue>(atom, options?): WritableAtomSignal<TValue>;Defined in: packages/angular-store/src/injectAtom.ts:44
Returns a WritableAtomSignal that reads the current atom value when called and exposes a .set method for updates.
Use this when a component needs to both read and update the same writable atom.
Type Parameters#
TValue#
TValue
Parameters#
atom#
Atom<TValue>
options?#
InjectSelectorOptions<TValue>
Returns#
WritableAtomSignal<TValue>
Example#
ts
readonly count = injectAtom(countAtom)
increment() {
this.count.set((prev) => prev + 1)
}