Skip to content

Commit

Permalink
docs(inject-inputs): add injectInputs
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed May 24, 2024
1 parent e6c741d commit e8af15a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/src/content/docs/utilities/Injectors/inject-inputs.md
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: '' }
}
}
```

0 comments on commit e8af15a

Please sign in to comment.