Nesting Reactive Forms in Angular tutorial

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 74

  • @Avaneesh_Mishra
    @Avaneesh_Mishra 3 года назад +8

    Amazing explanation. You almost covered everything about Reactive form in less than 30 mins. Well done. 👍👍

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Thank you! I’m really glad you enjoyed it😊👍

  • @sharpen81
    @sharpen81 3 года назад +4

    This is great! Please continue making similar tutorials since RUclips is really lacking quality Angular tuts. :)

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Thank you for the kind words. I’m really glad you are enjoying the content.
      My plan is to come back and keep making videos. I’ve just been really busy with work. Hopefully I’ll be able to finish some new ones soon 😊

  • @CraigShearer
    @CraigShearer 4 года назад +7

    Nice. For disabling if a form is invalid, I prefer to avoid the double negative and use [disabled]="form.invalid"

    • @TheRyanSmee
      @TheRyanSmee  4 года назад +2

      Good spot! Tbf I used `!form.valid` for a really long time until someone I work with pointed out `form.invalid` to me. I’m not really sure why I reverted back in this video 😂
      😬 but I really wish I had of spotted that in editing so I could have put a note on the screen or something haha.

  • @rembautimes8808
    @rembautimes8808 2 года назад +1

    Like your videos especially the witty lines . With forms being part of our life , good form design is like fine craftsmanship and tutorials like yours help us along. Stay safe and thanks for your excellent content

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Thank you for your kind words. I’m really glad you enjoyed this video 😊

  • @cloudsss83
    @cloudsss83 2 года назад +1

    Damn... You are the best tutorial guy I have ever watched. Thank you so much!!!

    • @cloudsss83
      @cloudsss83 2 года назад +1

      Please man, teach us! I'll buy any course you make, even testing lol

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Thank you for watching and commenting. I honestly really appreciate the love! I always said i'd find time to start making videos once I hit 1K, so looks like i'm back! haha

  • @WilmerBlanco
    @WilmerBlanco 9 месяцев назад

    Thanks for your video, It helps me a lot to understand form Array implementation. waiting more Angular videos.

  • @kcrowe8583
    @kcrowe8583 2 года назад +1

    Excellent tutorial. Very similar to what I need for my own project. I am so glad I found your content.

  • @rahulsudhakaran923
    @rahulsudhakaran923 3 года назад +1

    This is awesome , please make more complex reactive forms and common validation handling ways , keep rocking

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Cheers! I’m really glad you enjoyed it 😊

  • @SrinivasaKalyanParupalli
    @SrinivasaKalyanParupalli 3 года назад +1

    Why dint I see this video for last 2 days ... this is great.. thank you

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Thank you for watching and your comment 😊 I’m really glad you found it useful!

  • @scherschak
    @scherschak Год назад

    Hey! Thanks for your video! Really good explanation. Easy to listen you

  • @danilo_teixeira
    @danilo_teixeira 9 месяцев назад +1

    Excellent video man, congrats!

  • @radvilardian740
    @radvilardian740 3 года назад +1

    Another good Angular channel worth subscribe after Dmitro's one, thank tou for providing a good tutorial, Much appreciated 👍

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Thank you! I’m really glad you found it useful 😊

    • @radvilardian740
      @radvilardian740 3 года назад +1

      @@TheRyanSmee Do you plan to update your playlist, looks like you didn't update them often.

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      @@radvilardian740 - yeah I do plan to start making more content. It’s just been a really busy 6 months.

    • @radvilardian740
      @radvilardian740 3 года назад +1

      @@TheRyanSmee Nice to know that.

  • @sukanyaharidas4066
    @sukanyaharidas4066 2 года назад +1

    Excellent tutorial !

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Thank you for watching! I'm really glad you found it useful! 😊

  • @omaralebda
    @omaralebda 2 года назад +1

    Thank you so much for this tutorial. exactly what I was looking for (Y)

    • @TheRyanSmee
      @TheRyanSmee  2 года назад +1

      Cheers 😊 I’m really glad you enjoyed it

  • @davirodau
    @davirodau 3 года назад

    That was actually an amazing video mate! Keep it up!

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      Cheers mate, I’m really glad you enjoyed it! 😊

    • @davirodau
      @davirodau 3 года назад +1

      @@TheRyanSmee I loved it man...I'm struggling to build a child form with dynamic array for the checkbox and quantity for each, and I think this will help me solve the problem

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      I’m really glad! Hopefully you get it sorted 😊

  • @rupeshdulal4677
    @rupeshdulal4677 3 года назад +1

    Nice tutorial. Please do tutorials on Router Guards and Angular Security.

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      Hey, really glad you enjoyed it. Ok cool, I’ll add it to my list of videos to do this year.
      Cheers for watching and thanks for commenting!

  • @bug18486
    @bug18486 3 года назад +1

    Thank you for the great tutorial. I can use your technique refectory my code 😁

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      Thank you for watching and commenting. I’m glad you found it useful 😊

  • @soulofjack7294
    @soulofjack7294 3 года назад +2

    getting this error while passing data in childForm after looping.
    Type 'AbstractControl' is missing the following properties from type 'FormGroup': controls, registerControl, addControl, removeControl, and 3 more.

    • @zhaowentan8658
      @zhaowentan8658 2 года назад +2

      I got the error like below:
      error TS2339: Property 'controls' does not exist on type 'AbstractControl'.
      Instead of this:
      I changed to this:
      It resolved my problem. Hope it can help you out.

    • @kristerss
      @kristerss Год назад

      try: [childForm]="$any(childForm)"

  • @zhaowentan8658
    @zhaowentan8658 2 года назад

    Excellent tutorial that I am looking for a couple of days. But one more question, when I followed your video, the below line cannot compile.
    this.userContactForm = new FormGroup( controls: {

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Sorry for the delay. I've seen a few comments like this - What version of Angular are you using?

  • @andreip.8321
    @andreip.8321 Месяц назад

    why not implement ControlValueAccessor?

  • @OlugbenroSelere
    @OlugbenroSelere Год назад

    Hi how would you implement this in an edit scenario?

  • @risoledoce
    @risoledoce 2 года назад +1

    Hi! Should I use .hasError('required') or .errors?.['required']?

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      I can’t think of any reason why both wouldn’t work, but I think I’d likely go with .hasError(‘required’)

  • @mytho2630
    @mytho2630 2 года назад +1

    Thank you!

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Thank you for watching! I’m glad you enjoyed it 😊

  • @fejugaism
    @fejugaism Год назад

    As to me, bit over-engineered.
    There is no need for separating out static method in to the child component. This method is not actually used by the child component and its result is being circled back by Input(). I'd say, using static method is a red flag that service or util pure function should be used instead.
    The idea of nested form groups is actually pretty simple - create all forms wth form builder and pass them down to the child component.
    Otherwise, pretty cool example of using reactive form, inputs and outputs. Thanks!

  • @pgc1721
    @pgc1721 3 года назад +1

    fantabulous :-D

    • @pgc1721
      @pgc1721 3 года назад +1

      Subscribed too :-)

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      Really glad you enjoyed it! And thank you so much for the sub 🙏

  • @soulofjack7294
    @soulofjack7294 3 года назад +1

    exactly what i want

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      I’m really glad you found it useful 😊

  • @saeidm4884
    @saeidm4884 9 месяцев назад

    If you don't import ReactiveFormsModule in your components in Angular 17 you will get several errors, so if you have errors make sure you are importing it. Took me a while to figure it out as errors where not pointing to that.

  • @alainkr
    @alainkr 2 года назад

    Lovely

  • @poojar.4184
    @poojar.4184 3 года назад +1

    Which editor used in this project

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      Hi. I am using WebStorm with the Gradianto theme. Thanks for watching 😊

    • @poojar.4184
      @poojar.4184 3 года назад +1

      @@TheRyanSmee thanks and can i appy this code on vs code editor

    • @poojar.4184
      @poojar.4184 3 года назад +1

      Thanks a lot for upload this forms🤗In this form nested reactive form and form array this two concepts are same or different?

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +2

      No they should work in the same way. You can either have the form array at the parent level with inputs nested below like in this video. Or you would even house a form array in the child component and the value that is passed up to your parent through the value accessor is an array.
      Does that make sense?

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      @@poojar.4184 yeah 100%. I use Webstorm because I’m used to it but my colleagues do the same job with vscode 😊

  • @manojswain6507
    @manojswain6507 Год назад

    nested array ??? (array inside array
    )

  • @astrid0m
    @astrid0m Год назад

    understood nothing. =(

  • @hero1v1
    @hero1v1 2 года назад +1

    Complicating file structure defeats the purpose of the video. Keeping it simple is the way to go. Imagine someone new to angular trying to follow your angular nested forms tutorial, i mean someone who never heard about clean code.

    • @TheRyanSmee
      @TheRyanSmee  2 года назад +2

      Hi 👋 Thank you for watching my video and commenting, but I’m afraid I’ll have to disagree. This is not a beginner tutorial for people who have never written angular before. It’s for people who work with medium to large angular projects and are looking to write good, reusable code that scales well.
      If a developer has never heard of writing “clean code”, the best thing we can do as leaders in to inform them off it’s importance.
      In my experience, when working with a larger code base, the organisation of your code is as important as the code itself.
      I hope this all makes sense 👍

    • @hero1v1
      @hero1v1 2 года назад

      @@TheRyanSmee but title is not about clean code, and its not saying not for beginners, also nesting forms its not for large code base . im just giving you a feedback on why i skipped the video,

  • @williamt.roberts4771
    @williamt.roberts4771 2 года назад +1

    *ngFor="let childForm of userContactForm.get('contacts').controls " red line under "controls" error : Property 'controls' does not exist on type 'AbstractControl'.ngtsc(2339)
    What is the issue do you think?

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      What version of angular are you using?

    • @TheRyanSmee
      @TheRyanSmee  2 года назад

      Have you tried ``?

  • @rr3861
    @rr3861 3 года назад +2

    why not use ControlValueAccessor?

    • @TheRyanSmee
      @TheRyanSmee  3 года назад +1

      Hi, first of all, thanks for watching! 😊
      I’ve actually got another video on doing exactly that - ruclips.net/video/xTcJQaWiJ2c/видео.html
      For me, I think control value accessors are better for making a single form control. So if I wanted to make a password input with a show side toggle, that’s when I’d use an value accessor

    • @rr3861
      @rr3861 3 года назад +1

      ​@@TheRyanSmee it's looks good, its probably more hassle with CVA. I think you don't need to cast in that case (I May be wrong)

    • @TheRyanSmee
      @TheRyanSmee  3 года назад

      @@rr3861 yeah as you say I think either could work and they both would do a pretty good job it’s probably more down to which one you feel works best for the specific use case