Topic: Display input error messages if data-error binding != null

nate pro asked 6 years ago


My rest service returns an object containing validation messages for given fields.   heres an example object: formErrors: { "globalMessage": null, "fieldErrors":  { "emailAddress": "Email address must more than six characters. ", "password": "password must be at least 8 characters" } } the idea is matching field names would have their respective error messages bound to them. is there anyway for me to just simply bind the the error message directly to the field without having to use the mdbInputValidate directive? I'd like server side messages to get bound to the fields, i'm lazy id rather only use server side validation then both client and server.   the associated template could look something like this: <divclass="md-form">       <iclass="fa fa-envelope prefix grey-text"></i>      <inputtype="text"id="form3"class="form-control validate invalid"data-error="{{formErrors.fieldErrors.password}}"mdbActive [(ngModel)]="credentials.password" />     <labelfor="form3">Password</label> </div>    

nate pro commented 6 years ago

Incase anyone else runs into this issue kmckinley Pro User answered 1 year ago: I ran into this same issue using it with Angular2. My solution was to just check the model that it wasn’t null and it’s length was greater than 0. If so then I add the .active class 0" for="city">{{ 'City' | translate }}


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No
Tags