Learn How to Create Dynamic Component in Angular

Поділитися
Вставка
  • Опубліковано 10 лис 2024

КОМЕНТАРІ • 75

  • @joaor.g.castaldi6753
    @joaor.g.castaldi6753 Рік тому +1

    Wow, it's been very long since I first saw the ngComponentOutlet, but I was never able to find a real use for it (I though that was too complicated and was simpler to just do an *ngIf), after this lesson I'm so excited to apply it in a lot of my old codes. This is just gold! Thank you so much for this lesson.

  • @wasiullahkhan9685
    @wasiullahkhan9685 2 роки тому +6

    I'm getting started with Angular and spent so much time on the docs to understand dynamic component loading but the official resources are confusing, sporadic and inorganic. This tutorial actually saved me so much time, thanks Profanis!

  • @richnimbu
    @richnimbu 2 роки тому +3

    I love how you display the various stages of how to complete this task. Very well explained!

  • @tonis237
    @tonis237 9 місяців тому

    I was getting so worked up on how to work with dynamic components because the other tutorials i found are either too old and use the componentFactory or don't explain it well.
    You explained it just the way i needed it. Thank you, Profanis!

  • @elialvarezmelgar9301
    @elialvarezmelgar9301 11 місяців тому +1

    You explain superb...!!! The example is concise, enough & useful... Please... keep making more videos... your channel will grow because of there are many angular channels but only your channel is wow!!!

  • @ISBE91
    @ISBE91 Рік тому +1

    Finally someone explains how to load component in angular without any spaghetti code
    Thanks!

  • @fatihersoy7559
    @fatihersoy7559 2 роки тому +1

    Pretty explanatory and simple video. Great job Profanis, greetings from Turkish neighbour! :)

  • @juandaleonardo6466
    @juandaleonardo6466 2 роки тому +2

    hey profanis, i love this kind of angular course. thank you!

  • @ansaganie
    @ansaganie 9 місяців тому

    Thanks, Profanis! very Insightful! Looks like this is how 'ng-dynamic-component' lib works under the hood

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  9 місяців тому

      Oh I didn't know a library for dynamic components was out there. Thanks for that

  • @longebor85
    @longebor85 Рік тому +1

    Awesome job, Mr. Profanis. Thank you very much

  • @snk-js
    @snk-js 2 роки тому +1

    loved this video, I was long life react, but Im trying to see the things from angular perspective now, and this video was really good, keep the good work

  • @georgianstan8300
    @georgianstan8300 2 роки тому

    Great content. One thing to mention here! For lazy-loading to take place the import statements for WidgetOneComponent and WidgetTwoComponent needs to be removed. Their only reference needs to be kept inside componentsConfig

  • @ekzGuille
    @ekzGuille Рік тому +2

    Hi! it's important to mention that ComponentRef.setInput() method is available in Angular 14.1.0

  • @Nabulio85
    @Nabulio85 Рік тому

    Really great explanations and use case.
    Thank you. 🙏

  • @JesseJotun
    @JesseJotun 2 роки тому +2

    Is the setinput method typed to only inputs of the component? When using the setinput method you won't realise your app is broken if you renamed an input until you try to create it at runtime. The old way you would get an error at compile time. Any way around that?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  2 роки тому +1

      Yeah unfortunately the setInput() is not typed. I do not have any workaround on this but I will give it a shot

  • @youssefchaygani8518
    @youssefchaygani8518 2 роки тому +1

    This is some good stuff here, thanks for making this version update so clear.
    You got yourself a new subscriber and a share.

  • @avecesar
    @avecesar Рік тому

    Thank you for such a clear explanation.

  • @ezemans
    @ezemans Рік тому +1

    Awesome content! In my case I had to use a ComponentFactoryResolver before creating the component, and It's worked!

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  Рік тому

      Which angular version do you have?
      Please note that since Angular v13 it's not required to resolve a factory
      angular.io/api/core/ComponentFactoryResolver

    • @ezemans
      @ezemans Рік тому +1

      @@CodeShotsWithProfanis I'm using Angular 8. You are right, it's not necessary for Angular 13.

    • @AnuragSingh-ev8qd
      @AnuragSingh-ev8qd Рік тому

      Hi Ezequiel, needing one help here. I'm using angular 12 and trying to do the same.
      But when I pass component instance to factoryResolver, it's giving me an error 'Argument of typeof component is not assignable to parameter of type 'Type.
      Please suggest what I'm doing wrong here. Thanks

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  Рік тому

      ​@@AnuragSingh-ev8qd Can you provide a piece of code that you are using or crate a stackblitz instead?

  • @youknowwho4994
    @youknowwho4994 Рік тому

    Thanks for the video. Its very crisp and clear. May i know what vs code you are using to show the types directly. I mean i can see the "obj:" in the @component. Thanks in advance.

  • @KostasOreopoulos
    @KostasOreopoulos Рік тому

    Great tutorial.
    Shouldn't we pass environmentInjector: inject(EnvironmentInjector) to the createComponent to give it access to the DI hierarchy?
    I am just guessing.

  • @madpwnz
    @madpwnz 2 роки тому +1

    Woohoo! New video!!!

  • @jacobadlerman3067
    @jacobadlerman3067 2 роки тому +1

    Yeah, it more understandable in comparison with a documentation, thanks a lot :)

  • @anvianshi
    @anvianshi Рік тому +1

    Thank you for explaining so clearly the concept of creating Dynamic Component. It would be really helpful if you could also explain when this concept should be used when creating an application. TIA

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  Рік тому

      Glad you liked it! :)
      A use case would be to create a dashboard with widgets.
      Flow: A user selects which widgets wants to have on the dashboard, this info is persisted in the DB, and then upon page reload we fetch this list and we can then create these widgets/components dyncamically

  • @ReflexaoEPalavra-lucascota
    @ReflexaoEPalavra-lucascota Рік тому +1

    Oh, my friend, excellent content. Is it possible to create real-time components with data coming from an api? all dynamic?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  Рік тому

      Yes that would be possible. Please come back and reply to this video if you tried and worked for you

  • @SunnyVakil
    @SunnyVakil 2 роки тому

    Super explanatory , thank you!

  • @ellsonmendesYT
    @ellsonmendesYT 6 місяців тому +1

    what is the name of that extension wich shows labels on objc ViewChild(selector:'container', opts: {read:ViewContainerRef}) ?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  6 місяців тому

      If I understood correctly what you are referring to, it is a setting in VSCode.
      // This displays the parameter names
      "typescript.inlayHints.parameterNames.enabled": "all"
      // This displays the variable types
      "typescript.inlayHints.variableTypes.enabled": true

    • @ellsonmendesYT
      @ellsonmendesYT 6 місяців тому

      @@CodeShotsWithProfanis thank you sir!

  • @ahmedrebai6042
    @ahmedrebai6042 Рік тому

    What advantage I will get if I will implement dynamic components?

  • @MG-wx8yx
    @MG-wx8yx 2 роки тому

    Your new subscriber here. Excellent explanation in all your videos. I learned a lot.

  • @sofiachaveshernandez2373
    @sofiachaveshernandez2373 2 роки тому

    Hi Profanis : )
    Thank you for the video! Can this also be done with a non-standalone component?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  2 роки тому

      I had a talk explaining how to achieve that. It is worth checking this out :)
      ua-cam.com/video/qJW73J3obpY/v-deo.html

    • @sofiachaveshernandez2373
      @sofiachaveshernandez2373 2 роки тому

      @@CodeShotsWithProfanis Thank you very much, I'll check it out : )

  • @byzadev
    @byzadev Рік тому +1

    Amazing!

  • @dannypacheco4425
    @dannypacheco4425 Рік тому +1

    i have this error: Cannot read properties of undefined (reading 'clear'). Im using Angular 13. Could you help me please?

  • @CrusaderMen
    @CrusaderMen 2 роки тому

    Thank you, this can be used to create creative things

  • @aram5642
    @aram5642 9 місяців тому

    A real fun begins when the widget components are also meant to provide output (maybe they contain forms).

  • @imwichop
    @imwichop 2 роки тому +1

    I want to pass a specific method for each child component. It is possible? and how can I do it?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  2 роки тому

      Can you please explain further what do you mean by saying "pass a specific method"?

  • @maxim1106
    @maxim1106 2 роки тому

    do you know how to connect to the template module dynamically depending on the condition,
    for example for different countries that need to display a form, there are inputs and outputs?

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  2 роки тому

      I am afraid I do not get what you mean by "connect to the template module"
      Can you please be more specific by providing an example?

  • @ugochukwuumerie6378
    @ugochukwuumerie6378 2 роки тому

    Awesome, great video

  • @urtaav639
    @urtaav639 Місяць тому

    Como conecto esos componentes a un formulario reactivo ?

  • @anguinan
    @anguinan 9 місяців тому

    createComponent() won't compile when components doesn't have same attributes due to typing errors. Didn't find a solution yet...

  • @mohammeddarwish7858
    @mohammeddarwish7858 4 місяці тому

    this is great, but how does this work when I'm reading from json file ? I mean how to save the component : () => ... and read it from json config file , if we save it json, when we return back the json then the import will be string !!! !!!

    • @CodeShotsWithProfanis
      @CodeShotsWithProfanis  4 місяці тому

      I am not sure which flow you are following to persist/get the JSON, but based on what you described, it seems to me that you might need to JSON.parse your JSON.