Component-Less and Empty-Path Routes in Angular (2023)

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • 💥 Become a PRO with my in-depth Angular Forms Course💥
    🔗 10% discount for the first 10 students - bit.ly/advanced-ng-forms-disc...
    In this video, you will learn what component-less and empty-path routes in #angular are. You will see some use cases when this pattern might be helpful and help you to make your code base more reliable and flexible. I hope you will learn something new today and if so, please share this video with your colleagues and friends.
    🕒 Time Codes:
    00:00:00 - Intro;
    00:00:27 - Describing a use case;
    00:03:52 - Component-Less & Empty-Path routes in Action;
    00:11:56 - How to become a PRO in Angular Forms;
    🙌 Support Dmytro bit.ly/donate-to-decoded-fron...
    💡 Short Frontend Snacks (Tips) every week here:
    Twitter - / decodedfrontend
    Instagram - / decodedfrontend
    LinkedIn - / dmezhenskyi
  • Věda a technologie

Komentáře • 81

  • @laluprasad3775
    @laluprasad3775 Před rokem +7

    Please make Angular series please ,i want to learn angular.from.you.please

  • @AlainBoudard
    @AlainBoudard Před rokem +9

    Excellent Angular content !
    As usual, very useful content !

  • @MrForexify
    @MrForexify Před rokem +1

    Thanks mate!

  • @rahultej8352
    @rahultej8352 Před rokem +1

    very very useful

  • @nicosaliagas
    @nicosaliagas Před rokem +1

    Excellent many thanks 👌

  • @azeemjoseph3946
    @azeemjoseph3946 Před rokem +1

    thanks for the video, Great content ...!!

  • @haroldpepete
    @haroldpepete Před rokem +2

    great video, your videos are better and better

  • @arkabhowmick
    @arkabhowmick Před rokem +5

    Note: If someone is updating their routes to component-less routes after watching this video, just make sure to check if there is any router.navigate() using relative paths inside those child components (e.g. router.navigate(['../parent', { relativeTo: currentRoute }])). That may need to be updated.

  • @chagamajaykumarreddy1897

    very usefull tip

  • @malikau917
    @malikau917 Před 3 měsíci

    Wow that’s some useful stuff!

  • @uidhtml
    @uidhtml Před měsícem +1

    Awesome video.. 👌👌

  • @dimitridovgan6364
    @dimitridovgan6364 Před rokem

    Thank you!

  • @spzanoosi3237
    @spzanoosi3237 Před rokem +1

    Awesome as Always!

  • @muhammadghaderi4611
    @muhammadghaderi4611 Před rokem +1

    Very useful! Many thanks for sharing

  • @arny699
    @arny699 Před rokem

    Super useful! As usually. Thank you!

  • @gagiksimonyan3782
    @gagiksimonyan3782 Před rokem +1

    Thanks for another useful video, Dmytro

  • @ali-celebi
    @ali-celebi Před rokem

    Excellent video as usual.

  • @AlesFrankie
    @AlesFrankie Před rokem +1

    Every time something new, thanks!

  • @wilder_kh
    @wilder_kh Před rokem +1

    Thanks for the video!

  • @angelpellejero8764
    @angelpellejero8764 Před rokem

    Super interesting as always, thanks!

  • @denisbielishev
    @denisbielishev Před rokem +1

    Thanks a lot. As usual, it's a very useful video.

  • @volodymyralexandrov6040
    @volodymyralexandrov6040 Před rokem +1

    Nice feature! Thanks ❤

  • @udithamax7
    @udithamax7 Před rokem

    Great content as always.. keep it up.. 👍🤘

  • @OfficialVideos482
    @OfficialVideos482 Před rokem +1

    Awesome 🤩

  • @krzysztofprzybylski2750
    @krzysztofprzybylski2750 Před rokem +1

    Interesting video. I found myself using componentless routes for routed modals. That way angular doesn't complain about route not existing. What I haven't realized is that it worked only because I used it in lazy loaded modules. I'm currently searching for a better solution.

  • @beodan9219
    @beodan9219 Před rokem

    excited

  • @user-wh4pm2bj1q
    @user-wh4pm2bj1q Před rokem

    Nice!

  • @wiliamferraciolli5380
    @wiliamferraciolli5380 Před rokem +1

    thats amazing mate, can you do some more around routing, especially resolving data when navigating to a route including refreshing the page

  • @alexshubin1
    @alexshubin1 Před rokem

    thanks, very interesting, never used this feature before. Before watching this video I supposed this was about routes that do not show anything (empty or dummy template) but just redirect user to another page. For example when user click some confirm link in email, the frontend just post data to the server and redirect to another (public) page instantly.

  • @ankitpandey8614
    @ankitpandey8614 Před rokem +1

    Really liked your videos man. Please make videos on angular application architecture

  • @dmytrosokolovsky8959
    @dmytrosokolovsky8959 Před rokem +1

    Дякую за цікаве та корисне відео 👍
    Вперше прийшов до цього методу, коли потрібно було навісити резолвер на декілька роутів та не хотілось копіпастити
    Якби на інтервью запитали щось про "Component-Less and Empty-Path Routes" навіть не здогадався би про що мова)

    • @DecodedFrontend
      @DecodedFrontend  Před rokem +1

      В мене часто було таке на співбесідах коли я забував яка «офіційна» назва тієї чи іншої фічі)) тож пояснював своїми своїми словами

  • @superduper1211
    @superduper1211 Před rokem +2

    Dima , your room now is not looking that empty )) good job ))

  • @THIAGO_6721
    @THIAGO_6721 Před 10 měsíci

    Incredible

  • @pawekoaczynski4505
    @pawekoaczynski4505 Před rokem +6

    Great video c:
    I have a small tip: at 6:19, you can put your cursor on the `=>` and press `Ctrl + .` which allows you to quickly add `return` to the arrow function c:

  • @souhaibkhadraoui9898
    @souhaibkhadraoui9898 Před rokem

    Again, great content ! Could you make a video on Angular RouteReuseStrategy and its use cases ?

  • @konradchojnacki8438
    @konradchojnacki8438 Před rokem

    Great content, that technique could be useful in some scenarios. I really like the idea of providing in-depth angular form course. I hope oneday to see similar course about angular PWA, imo there is a lack of up-to-date materials to become comfortable with the topic.

  • @dhineshrajendran3277
    @dhineshrajendran3277 Před rokem

    Great!. Can you make a video about custom decorator?

  • @GunjanShrimali
    @GunjanShrimali Před 5 měsíci

    very nice

  • @madeOfClay99
    @madeOfClay99 Před rokem

    Useful video as always!
    Personally, I'm still waiting for the remake of your Angular Material theming course : )

  • @PaweKubiak94
    @PaweKubiak94 Před rokem +1

    I used it a few days ago, but tbh I wasn't sure if it will work as I thought ;)
    Btw `discount` keyword works ;) haha

  • @dogandipcin
    @dogandipcin Před rokem +1

    You are the best Dmytro😍

  • @ihorsnisar7420
    @ihorsnisar7420 Před rokem

    Thank you very much for your work, very interesting and informative material.
    can you make a series of videos about the ubiquitous language and domain oriented design (ddd) in Angular?
    What is it, how is it customary to implement it in Angular, what difficulties can there be, what will it give in the end ....
    Once again, thank you very much for your work.

  • @c01nd01r
    @c01nd01r Před rokem +1

    Hey, thanks for the video!
    I don't use Angular, but it would be interesting to try.
    In real life apps, developers create Route objects as literals in the routing files?
    What about type safety and possible typos in the routerLink path directive?

  • @Bukratusi
    @Bukratusi Před rokem

    please make more frequent videos and complete playlista nd courses

  • @onodirobert
    @onodirobert Před rokem +1

    Thank You! But why are you use inject function instead of common guard class? Is it better? Have you any video about inject function usage? Thank you!

    • @darwinwatterson1732
      @darwinwatterson1732 Před rokem +1

      It is a new feature the Angular Team recently introduced, I think it works the same, but it is treeshakable

  • @kailashpatisinghdeora3677

    Nice it is handy approach for reusabliliy, Dymtro can you create a video on Dom Sanitization please and how attacker add malicious code in angular.

  • @osamaabozahra
    @osamaabozahra Před rokem +2

    Thanks for the video, very interesting concept.
    But Does it work with lazy loaded routes?

  • @pollo_cesar_
    @pollo_cesar_ Před rokem

    Nice, I think I tried in older angular version (11 or 8), this is something for 14 or 15 version?

  • @genyklemberg
    @genyklemberg Před rokem +2

    Great. I have a questions.
    What if user data is changed? Routes won't know that until we reload them?

    • @DecodedFrontend
      @DecodedFrontend  Před rokem +1

      Hi:) yes, you would need to re-activate the route to fetch the new data or use some other techniques to implement polling/reloading logic

    • @genyklemberg
      @genyklemberg Před rokem

      @@DecodedFrontend thanks;)

  • @stepandemchenko9870
    @stepandemchenko9870 Před rokem +1

    What about canLoad guards, when I need lazy load specific array of routes?

    • @DecodedFrontend
      @DecodedFrontend  Před rokem

      It works with any guard) p.s keep in mind that canLoad guard is deprecated in favor of canMatch

  • @brampeirsful
    @brampeirsful Před rokem

    Very nice!

  • @loko1944
    @loko1944 Před rokem +1

    I learned resolvers once, then I heard its bad because it is synchronous and its better to load data in component. Could You clarify this? Seems like good feature... Anyway great explanation as always. Its awesome you describe use case before exmplaining solution

    • @lukaszpiotrluczak
      @lukaszpiotrluczak Před rokem +1

      Resolvers are great, especially when you implement loading state handling. With a little bit of work you can easily create nice user experience around that. You can use resolvers for essential data required for component withoit which it will not work properly. This way you don't have to repeat loading stste logic in all components.

  • @MikelAingeru
    @MikelAingeru Před rokem +1

    Great video!!
    I guess if the user had a global logout button and press it in one of those child routes, since the canActivate guard it's not triggered, could be a problem, isn't it?
    In such a case, what would happen with the user resolver? Would it return the empty user or would it not be reactivated?

    • @DecodedFrontend
      @DecodedFrontend  Před rokem +1

      No, it should not be a problem. If you log out you usually don’t need to trigger canActivate guard. You just remove authentication token, etc and redirect to “login” page

    • @degloman
      @degloman Před rokem

      @@DecodedFrontend In some cases removing the authentication token can't work properly. For example you have a form and want to ask the user if he sure to logout without saved shanges. It makes sense to logout via /logout route and use the canDeactivate guard.

  • @TheSaceone
    @TheSaceone Před rokem

    nice strategy, but how could you redirect to another route if for example user is not authenticated?

    • @Netrole
      @Netrole Před rokem +3

      You can inject Router in the Guard and navigate to a new url from within the guard. In this case with the isAuthenticated$ observable you can pipe it through a tap function that navigates to /login if the value is false

    • @DecodedFrontend
      @DecodedFrontend  Před rokem

      Thank you, @Netrole for assistant :)

  • @NH-yv7im
    @NH-yv7im Před rokem

    Hi

  • @janeshwarsritharan3698
    @janeshwarsritharan3698 Před rokem +1

    will this also work if I have lazyily loaded children?

  • @EtoBARAKUDAvasa
    @EtoBARAKUDAvasa Před rokem +3

    "it's easy to forget to install the guard when there are many routes"? Seriously?
    This structure looks difficult even for the eyes. Yes, the code will be reduced but what is the profit? When you have at least 10 routes(and using more than one guard for all) with such a structure, you will be amazed by the complexity structure.
    But yeah, cool approach if you're alone on the project.

    • @pavlonaduda8329
      @pavlonaduda8329 Před rokem +1

      Imagine you have a schematic which add some page with nested components to your project. Also this schematic add a new route with this page.
      In this situation current approach is very useful, such as you don't want have a guard logic into schematic and just describe it into your routing module.

    • @DecodedFrontend
      @DecodedFrontend  Před rokem +1

      Hi,
      Thanks for the feedback. You can always extract the component-less route config in the separate file, give a meaningful name to that constant and just import it to the main router config, so the main config will remain lean and readable.

  • @devxbasit
    @devxbasit Před 6 měsíci

    insighful