2.5.1 • Published 11 months ago

@ildug/ngx-errors v2.5.1

Weekly downloads
2
License
MIT
Repository
github
Last release
11 months ago

ngx-errors

Publish Node.js Package Build and Test

Form errors display directives for Angular.

Updated to Angular 18.

try a demo

Install

Install via package manager or fork this project ("projects/ngx-errors/src")

NPM

npm install @ildug/ngx-errors

Usage in angular app

Import the module in your angular component. In your module app.module.ts

    ...
@Component({
    ...,
    standalone: true,
    imports: [..., ReactiveFormsModule, NgxErrorsModule],
    ...
})
export class AppComponent {
    form = new FormGroup({
        "email": new FormControl(null, [Validators.required, Validators.email])
    });
}

Form errors display

Add the directive to an element where errors will be diplayed.

dagErrors is the name of the reference input element.

dagError is the error name issued by Angular Validator

when indicates when the error message will be shown.

In my.component.html

<form [formGroup]="form" >
    ...
    <div class="my-input-container">

        <input type="email" formControlName="email">

        <div dagErrors="email" class="error">
            <div dagError="required" when="touched"> Please, insert a value</div>
            <div dagError="email" when="touched"> Ops, incorrect email format</div>
            <div dagError="otherError" [when]="[dirty, pristine]"> always show this message when otherError is present</div>
        </div>

    </div>
    ...
</form>
2.5.0

1 year ago

2.5.1

11 months ago

2.3.0

2 years ago

2.4.0

2 years ago

2.4.3

2 years ago

2.4.2

2 years ago

2.2.0

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

1.0.1

5 years ago

0.1.0

5 years ago