You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We often use in our Boostrap project the following directive, that automatically adds the is-invalid class depending on the control state and valdemort config:
/* tslint:disable:directive-selector */import{Directive,HostBinding,Optional}from'@angular/core';import{NgControl}from'@angular/forms';import{ValdemortConfig}from'ngx-valdemort';/** * Directive that dynamically adds/removes the CSS class is-invalid, used by Bootstrap 4, on * elements which already have the form-control Bootstrap CSS class, based on the * validity of the NgControl directive also present on this element and on the rules * configured by the ValdemortConfig service to decide when the validation errors should be displayed. */
@Directive({selector: '.form-control'})exportclassInvalidFormControlDirective{/** * Constructor. * @param ngControl the NgControl directive (if any), which can in fact be the NgModel directive, or the formControlName * directive, or any other directive that extends NgControl * @param config the ValdemortConfig service, used to know when the is-invalid class must be added */constructor(@Optional()privatengControl: NgControl,privateconfig: ValdemortConfig){}
@HostBinding('class.is-invalid')getisInvalid(){returnthis.ngControl&&this.ngControl.invalid&&this.config.shouldDisplayErrors(this.ngControl.control,(this.ngControlasany).formDirective);}}
We could include this directive (maybe in a dedicated valdemort-boostrap module?) or at least document it in the Bootstrap 4 integration section.
The text was updated successfully, but these errors were encountered:
We often use in our Boostrap project the following directive, that automatically adds the
is-invalid
class depending on the control state and valdemort config:We could include this directive (maybe in a dedicated valdemort-boostrap module?) or at least document it in the Bootstrap 4 integration section.
The text was updated successfully, but these errors were encountered: