Ionic Tutorial #9 - Error message component for form validation

Ionic Tutorial #9 - Error message component for form validation

IT with Paulo Alves

2 года назад

10,061 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@faisalpheonix8800
@faisalpheonix8800 - 24.09.2021 11:31

is TDD really necessary to use?

Ответить
@johncarpiano4823
@johncarpiano4823 - 05.11.2023 17:28

hello sir i have a little problem about this,

Multiple form field elements in the same form have the same id attribute value. This might prevent the browser from correctly autofilling the form.
To fix this issue, use unique id attribute values for each form field.

its because if i click the password it goes up not like email if i click the input will stay

this is my input in password:

<ion-input name="password" formControlName="password" label-placement="floating" label="Password"
type="password" ></ion-input>

I've been stuck here its really awkward when i click the input password sir. :)

Thank you ;)

Ответить
@makler8871
@makler8871 - 21.07.2023 10:12

kurwa nie słychać cię

Ответить
@freewalker208
@freewalker208 - 20.07.2023 12:17

For anyone who got error at file login.page.html, line "<app-error-message [field]= "form.get('email')" error="required" message="Email is mandatory"></app-error-message>", here is how to fix:

// change the field type
@Input() field!: AbstractControl<any, any> | null;
// also, update the if statement to
if (this.field?.touched && this.field.errors?.[this.error])

Ответить
@garaisq
@garaisq - 22.03.2023 04:13

Even after changing the code for AbstractControl, I am getting the following error. Has someone experienced the same? How could you solve it? Thank you

I am still getting an error in the [field] in login.page.html . My error is: TS2322: Type ‘AbstractControl<any,any> | null’ is not assignable to type ‘AbstractControl<any,any>’. Type ‘null’ is not assignable to type ‘AbstractControl<any,any>’

Ответить
@HOSTRASOKYRA
@HOSTRASOKYRA - 16.01.2023 01:10

I had the error Failed: Cannot read properties of undefined (reading 'touched')
I added check for undefined in error-message.component.ts
shouldShowComponent() {
//*ngIf="form.get('email').touched && form.get('email').errors?.['required']"
if (this.field === undefined)
return false;

if (this.field.touched && this.field.errors?.['required']) {
return true;
}

return false;
}
also i changed declaration to
@Input() field: AbstractControl;

Ответить
@alhanouf4929
@alhanouf4929 - 19.10.2022 19:33

Hello sir

I have been facing this problem for days
please help me, I'm working on my senior project :=(

ErrorMessageComponent > should hide error message on field touched, but no errors
Failed: Cannot read properties of undefined (reading 'touched')

Ответить
@alhanouf4929
@alhanouf4929 - 17.10.2022 16:38

YOU HELPED US ALOOOOOOOOOOOT WITH OUR SENIOR PROJECT TYSM!!!

Ответить
@JonathanArleyMonsalveSalazar
@JonathanArleyMonsalveSalazar - 10.02.2022 06:20

I had a problem because I got "this.field is undefined" in the test, So I moved the
component.field = new FormGroup({email: new FormControl()});
inside the beforeEach

Thanks for the tutorial, really interesting the TDD stuff.

Ответить
@mohalquzi274
@mohalquzi274 - 30.07.2021 11:46

Hello,
I had this issue when writing:
<app-error-message [field]= "form.get('email')" error="required" message="Email is mandatory"></app-error-message>

The [field] part is giving me an error/warning, an under line red line, meaning something is not alright with my code, even if after following every step in the video for multiple times. However the app is running and functioning.

Error:
"Type 'AbstractControl' is missing the following properties from type 'FormGroup': controls, registerControl, addControl, removeControl"


After searching:
I found that from the file tsconfig.json.
Changing this part from "strictTemplates": true To "strictTemplates": false, did the trick.
I thought this might help someone. However not sure if this is ok on the long run.

Ответить
@jrdhvrk4388
@jrdhvrk4388 - 22.06.2021 14:36

Hi sir please help me. When Ever i try to run ""ionic cordova resources"" i get error of Cordova not installed in path, install Cordova globally.
I have installed Cordova already but i am still getting errors. Please help me i would really appreciate it.

Ответить
@vajidali9979
@vajidali9979 - 17.06.2021 18:36

Hello sir how to fatch data from firebase...

I want to fatch data with userId and CategoryId

Ответить