0.0.3 • Published 3 years ago

@ericlamb/ng-bs-forms v0.0.3

Weekly downloads
56
License
MIT
Repository
github
Last release
3 years ago

CI npm (scoped)

Angular BootStrap Forms

Provides components for using Angular Reactive Forms with BootStrap 4.5.

<form [formGroup]="loginForm" (ngSubmit)="submitForm()">
  <div class="container">
    <app-bs-form-field [formField]="userName" [icon]="'user'" [placeholder]="'username (or email)'"
      name="username" [autoFocus]="true">
      <app-bs-field-error *ngIf="userName.hasError('required')" [error]="'Username is required.'">
      </app-bs-field-error>
    </app-bs-form-field>
    <app-bs-form-field [formField]="password" [type]="'password'" [icon]="'key'" [placeholder]="'password'"
      name="password">
      <app-bs-field-error *ngIf="password.hasError('required')" [error]="'Password is required.'">
      </app-bs-field-error>
    </app-bs-form-field>
  </div>
  <div class="form-group text-right">
    <button class="btn btn-primary" (mousedown)="validateForm()">
      <fa-icon [icon]="['fas', 'sign-in-alt']"></fa-icon> Sign In
    </button>
  </div>
</form>

Text Inputs (app-bs-form-field)

<app-bs-form-field [formField]="userName" [icon]="'user'" [placeholder]="'username (or email)'" label="Username (or Email)" name="username" [autoFocus]="true">
</app-bs-form-field>
InputDescription
formFieldForm field to bind the contents of the input to.
placeholderPlaceholder text to display for an empty input
iconFont Awesome icon from the free solid icon collection to perpend to the form field.
nameName to apply to the input.
typeHTML input type to set the input field to.
autoFocusInput to focus when the control loads. Use once per form.
labelLabel to apply to the form field.

Displaying Validation Errors (app-bs-field-error)

To display validation errors add a app-bs-field-error under the app-bs-form-field. Use an ngIf to control when the error is shown. Set the text to display in the error input.

Example

<app-bs-field-error *ngIf="password.hasError('required')" [error]="'Password is required.'">
</app-bs-field-error>

Inputs

InputDescription
errorThe error to display.
0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago