No video

A simple approach to displaying form validation messages in Angular

  Рет қаралды 14,899

Joshua Morony

Joshua Morony

Күн бұрын

Пікірлер: 37
@JoshuaMorony
@JoshuaMorony Жыл бұрын
Join my mailing list for more exclusive content and access to the archive of my private tips of the week: mobirony.ck.page/4a331b9076
@baluditor
@baluditor 2 жыл бұрын
I love the fact that you expleind in detail what that #form="ngFrom" means. Thanks for that.
@additionaddict5524
@additionaddict5524 2 жыл бұрын
I use forms all the time and had no idea!
@bromptonhorsing8597
@bromptonhorsing8597 Жыл бұрын
I also appreciated that. It's difficult to find more technical yet simple explanation, would like to see more 🤔👀
@CraigShearer
@CraigShearer 2 жыл бұрын
Thanks Josh - the deep dive into FormGroupDirective (at 4:40) is really interesting and intriguing to see how it works under the hood. Seeing how events are wired up in host blew my mind :)
@magmarrex5939
@magmarrex5939 2 жыл бұрын
This channel is pure gold. I love how you touch the backside details.
@kaibe5241
@kaibe5241 Жыл бұрын
Everyone loves a good backside touch.
@Rollout123
@Rollout123 Жыл бұрын
Great Video...simple, concise, thorough. Perfect for explaining submit, validation, etc.
@solartcom
@solartcom 2 жыл бұрын
It's always a good day when I see a new upload from you !
@AlainBoudard
@AlainBoudard 2 жыл бұрын
Clean and simple approach, well done Josh !
@ranjanadeore2957
@ranjanadeore2957 2 жыл бұрын
Thank you sir for uploading great tutorials
@Billy_Herrington__
@Billy_Herrington__ 2 жыл бұрын
This looks to me so over complicated tbh. Why do you need #form, when you can just use form.markAllAsTouched() in submit method, and in template you will do like this ngif = control.touched && control.errors.required (or what ever your error is named)
@setiadiprawiryo3797
@setiadiprawiryo3797 2 жыл бұрын
+1
@OLIV3R_YT
@OLIV3R_YT Жыл бұрын
Thanks for explaining ngForm
@petraveryanov2572
@petraveryanov2572 2 жыл бұрын
Isnt it kinda standard approach? Except that strange 'onBlur' thing e.g.. if I entered invalid e-mail, then clicked submit, then entered valid e-mail I will still see validation error which is weird.
@mariosfrixou7003
@mariosfrixou7003 Жыл бұрын
I always use formly in my angular projects. Never bothered with angular’s FormBuilder and never had to be honest!
@jeremiasaragonbonilla2167
@jeremiasaragonbonilla2167 2 жыл бұрын
Amazing! Thanks Josh
@edavar6265
@edavar6265 2 жыл бұрын
Great video as always. Thanks!
@ankit0120
@ankit0120 2 жыл бұрын
already used it in a few places but the issue is I have [disabled] bind with form.invalid and it does not update until I click out of the field. so users will never get to know if the value is right or not. did you face similar issue ?
@JoshuaMorony
@JoshuaMorony 2 жыл бұрын
I don't disable form submit if the form is invalid - the user can still click the submit button and it will trigger showing the errors but won't actually submit the form. I don't know the in-depth UX reasoning behind this, but as far as I am aware this approach is preferable to disabling the submit button.
@andreafresu5009
@andreafresu5009 2 жыл бұрын
@@JoshuaMorony avoid button disabling is the best approach because of accessibility reasons. Great videos, just subscribed 👍!
@scuroguardiano9787
@scuroguardiano9787 Жыл бұрын
Can't we just mark form as dirty on submit? One line in component logic and much simpler conditions in template.
@dinesh.m7341
@dinesh.m7341 Жыл бұрын
Thanks bro
@rhatalos1997
@rhatalos1997 2 жыл бұрын
I think a good idea would be to create an error component, which displays default messages for the existing validators.
@daniellynch3724
@daniellynch3724 Жыл бұрын
How did you place the custom validator in like that? I always have to do a long call including a this bind, and have to inject the validator in the component constructor
@kandeepasundaram2501
@kandeepasundaram2501 Жыл бұрын
Is there a way to clear the form validation errors on focus of any fields?
@loko1944
@loko1944 Жыл бұрын
In this case we could also createForm.dirty in template instead of form.dirty, right? its still reference this same form
@ReadyVred
@ReadyVred 2 жыл бұрын
this is great, but how can you display a multiple error messages ? or maybe if the input have 2 condition like required and maxlength, so the message must be different on each validation.. how can we achieve that ? btw thanks for the tutorial
@JoshuaMorony
@JoshuaMorony 2 жыл бұрын
If you want something more complex (e.g. showing specific error messages for multiple validations) then I wouldn't recommend the approach in the video. You could add some more logic onto it to grab the specific validator that failed and write a custom message for it, but at that point I think you would be better served either by: creating your own custom component/directive that takes in the form control and displays an error message, or better yet just use one of the existing libraries for dealing with forms since people have already solved this problem.
@rajatnegi3896
@rajatnegi3896 2 жыл бұрын
How is the template html color coded in the ts file ? Or is it a ionic specific thing. Sorry i haven't used ionic yet.
@JoshuaMorony
@JoshuaMorony 2 жыл бұрын
The Angular Language Service extension handles syntax highlighting for inline templates
@nimitdesai93
@nimitdesai93 2 жыл бұрын
why is my gms softing like static?
@szymonlisiecki2789
@szymonlisiecki2789 2 жыл бұрын
nice video but imo music is too loud
@thanhcongpham5422
@thanhcongpham5422 2 жыл бұрын
👍👍
@mahmoudtarek745
@mahmoudtarek745 Жыл бұрын
Thanks for Your video. But to be honest i think this is too much for handling validation not a simple approach why you do not just use markAllAsTouched()
@jorgerenteral
@jorgerenteral Жыл бұрын
What do you think about the "createForm.controls.email.touched && createForm.controls.email.errors" syntax?
A trick to make your Angular Reactive Forms more... *Reactive*
8:07
Prank vs Prank #shorts
00:28
Mr DegrEE
Рет қаралды 9 МЛН
Harley Quinn's revenge plan!!!#Harley Quinn #joker
00:59
Harley Quinn with the Joker
Рет қаралды 27 МЛН
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 72 МЛН
Knowing this makes Angular typed forms WAY less awkward
5:03
Joshua Morony
Рет қаралды 10 М.
How to structure your Angular apps like a Googler
10:58
Joshua Morony
Рет қаралды 84 М.
Why I use a view model stream for my Angular templates
15:11
Joshua Morony
Рет қаралды 33 М.
Michael Jackson meets Princess Diana & Prince Charles
5:51
iconic
Рет қаралды 100 МЛН
Spend 278 Days To Build A Dream Water Park
18:06
Mr.Heang Update
Рет қаралды 277 МЛН
POACHED EGGS | how to poach an egg (perfectly)
7:57
Downshiftology
Рет қаралды 21 МЛН
The secret to understanding piped operators in RxJS (Advanced)
9:06
How to handle errors REACTIVELY with the async pipe
8:30
Joshua Morony
Рет қаралды 18 М.
Why use OnPush in Angular? Not for performance...
13:15
Joshua Morony
Рет қаралды 31 М.
Prank vs Prank #shorts
00:28
Mr DegrEE
Рет қаралды 9 МЛН