-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(inject-inputs): add injectInputs
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
docs/src/content/docs/utilities/Injectors/inject-inputs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: injectInputs | ||
description: ngxtension/inject-inputs | ||
entryPoint: inject-inputs | ||
badge: stable | ||
contributors: ['chau-tran'] | ||
--- | ||
|
||
`injectInputs` is a utility function that provides a reactive signal for all Signal Inputs in a Directive or Component as an object. This is useful for tracking the state of all Inputs in a component or directive without having to create the `computed` manually. | ||
|
||
```ts | ||
import { injectInputs } from 'ngxtension/inject-inputs'; | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
@Component({ standalone: true, template: '' }) | ||
class Foo { | ||
foo = input(1); | ||
bar = input(''); | ||
|
||
inputs = injectInputs(this, Foo); | ||
|
||
constructor() { | ||
console.log(this.inputs()); // { foo: 1, bar: '' } | ||
} | ||
} | ||
``` |