Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ngx-inject-control
Advanced tools
Readme
A painless and idiomatic way to create reusable form controls for Angular applications.
Battle-tested at Ezfire.
npm install ngx-inject-control@1.0.0
npm:
npm install --save ngx-inject-control
Yarn
yarn add ngx-inject-control
To use ngx-inject-control
you first need to create an InjectableControl
. An InjectableControl
is an Angular component with a property called control
of type AbstractControl
. Finally, the InjectableControl
must provide itself with the NGX_INJECTABLE_CONTROL
token.
For example, suppose you want to create a single email input you can use across you application.
<div class="email-container">
<label for="email-input">Email</label>
<input id="email-input" name="email" type="email" [formControl]="control" />
</div>
import {
InjectableControl,
injectableControlProvider,
} from 'ngx-inject-control';
@Component({
selector: 'app-email-input',
templateUrl: '...',
providers: [injectableControlProvider(EmailInputComponent)],
})
export class EmailInputComponent implements InjectableControl {
constructor(private readonly fb: FormBuilder) {}
readonly control = this.fb.control(null, [Validators.email]).
}
InjectControlNameDirective
is a standalone component and can by imported directly in a module or
component.
import { InjectControlNameDirective } from 'ngx-inject-control';
@NgModule({
declarations: [EmailInputComponent], // Injectable component must be in scope
imports: [InjectControlNameDirective],
})
<form [formGroup]="group" (ngSubmit)="onSubmit()">
<input name="name" type="text" formControlName="name" />
<app-email-input injectControlName="email"></app-email-input>
<button>Submit</button>
</form>
@Component({
selector: 'app-form',
templateUrl: '...',
})
export class FormComponent {
constructor(private readonly fb: FormBuilder) {}
readonly group = this.fb.group({
name: [null, Validators.required],
email: [],
});
}
On render, the injectControlName
directive will replace the email field in group
with the control
field of EmailInputComponent
. Validations are recomputed at the time of replacement.
InjectControlNameDirective
Input | Type | Description |
---|---|---|
injectControlName | string or number | The field or index to replace in the parent control. |
disable | boolean | Enable or disable the injected control. |
MIT
FAQs
Simple, reusable form components in Angular
The npm package ngx-inject-control receives a total of 0 weekly downloads. As such, ngx-inject-control popularity was classified as not popular.
We found that ngx-inject-control demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.