1

I'm building a app with Angular 4 ( with material ) and Laravel 5.4. In the login form I have 2 inputs text, login and password. The angular validator works ok, but, when the user submit the form, I can't show the callback of error in material input. (It checks the rules of the form in backend ( laravel 5.4 ) , for ex: min lenght) and return a http code 422 that I handle in Angular. I tried to patchValue() in :

this.form1[controls][login][errors]

for add a error object to show in front-end, but it is not possible.

in short, I need to add a custom error to show in material input error.

login.ts

login.html

<md-input-container class="mrgn-b-md">
    <input mdInput placeholder="Usuário*" type="text" formControlName="login">
    <md-error>It can't be blank.</md-error>
    <md-error>Min lenght = 6 (example).</md-error>
</md-input-container>
  • I believe this answer will work, https://stackoverflow.com/questions/43553544/how-can-i-manually-set-an-angular-form-field-as-invalid – Arun Jose Mar 17 '18 at 14:32

0 Answers0