Skip to content

injectInputs

Created by 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.

import { injectInputs } from 'ngxtension/inject-inputs';

Usage

@Component({ standalone: true, template: '' })
class Foo {
foo = input(1);
bar = input('');
inputs = injectInputs(this, Foo);
constructor() {
console.log(this.inputs()); // { foo: 1, bar: '' }
}
}