How to Use Angular @Input to Pass Data to Dynamically Created Components

Поділитися
Вставка
  • Опубліковано 26 лип 2024
  • If you’re using dynamically created components in Angular with *ngComponentOutlet, you’ve probably found it difficult to pass information between the parent and child components when needed. Typically you need to provide the info in the parent and then inject it within the child component. While it’s not necessarily difficult to do, it results in a lot of extra boilerplate code. It would be so much better if we could just use the @Input decorator like we’re used to. Well, guess what? Angular supports doing this exact thing as of version sixteen. In this video, I’ll show you how. Alright, let’s get to it.
    ------------------------------------------------------------------------------
    💖 Help Support the Channel:
    If you found this helpful and want to show some love, you can always buy me a coffee (buymeacoffee.com/briantreese)!
    ------------------------------------------------------------------------------
    🔗 Demo Link:
    stackblitz.com/edit/stackblit...
    ------------------------------------------------------------------------------
    📖 Chapters:
    0:00 - Introduction
    0:39 - Passing data the old way using the Angular Injector
    1:57 - Passing data the new way using the *ngComponentOutlet inputs object
    ------------------------------------------------------------------------------
    #angular #angular_developer #angulartraining #frontend #angularcourse #angular_components #dynamic_component_inputs #dynamically_created_components
  • Наука та технологія

КОМЕНТАРІ • 3

  • @AntonioSantana-ll8il
    @AntonioSantana-ll8il 4 місяці тому

    Thanks for sharing, I'm seeing all your amazing content!!!

  • @AntonioSantana-ll8il
    @AntonioSantana-ll8il 4 місяці тому +1

    Could you make a video talking about cdk portal???

    • @briantreese
      @briantreese  4 місяці тому +1

      That's a good idea. Thanks for the feedback!