1.0.4 • Published 7 months ago

needy-element v1.0.4

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

NeedyElement

An angular directive to shake a form field when it is invalid (needs attention).

My Skills

This library was generated with Angular CLI version 15.0.0.

Installation :wrench:

npm install needy-element

:warning: Note: Please don't forget to import the module NeedyElementModule, in the appropriate module when using in an Angular project.

Usage :woman_mechanic:

This directive was designed to be applied on a Mat-Form-Field in a Reactive form, and the prerequisites are:

  • a form group
  • form controls
  • control validation to trigger the directive

By default, the directive will shake an element when it has the "mat-form-field-invalid" class, but you can specify a different class to trigger the directive, when using it with other elements other than the mat-form-field.

Using on a mat-form-field (trigger when the field is invalid)

<div>
   <mat-form-field needy>
      <input matInput id="someId" 
        formControlName="someFormControl" required>
   </mat-form-field>
</div>

Using on a custom element (trigger when the specified class is added to the element)

<div>
  <input id="someElement" [needy]="trigger-class"/>
</div>

:warning: Note: The directive will trigger (shake the element) when the class is detected on the element, when adding it using the method below or some other method:

  document.getElementById('someElement').classList.add('trigger-class');

Examples :desktop_computer:

If you need more detailed examples, please visit: https://stackblitz.com/edit/stackblitz-starters-wvqznt?file=src%2Fapp%2Fapp.component.ts

1.0.2

8 months ago

1.0.4

7 months ago

1.0.3

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago