How to create a Nested Sidebar in Angular 18 with Material Components!

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 พ.ย. 2024

ความคิดเห็น • 61

  • @lshadowSFX
    @lshadowSFX 5 หลายเดือนก่อน +2

    Your content is SUPER USEFUL plus you don't only show the topic of the video itself but you also teach proper ways to do it when comunicating between components!

    • @ZoaibKhan
      @ZoaibKhan  5 หลายเดือนก่อน

      Thanks man! Glad you're finding it useful :)
      Everything we create goes through a process so it's important to understand the process as well, so that we can learn lessons for the future!
      Thanks for your input

    • @lshadowSFX
      @lshadowSFX 5 หลายเดือนก่อน

      @@ZoaibKhan I trully love your content! It is super easy to follow, it does feel like you always know what you are doing and not just "guessing" like a lot of people! your channel is super instructive! new subscriber here!
      Could please make a tutorial on how to properly migrate to angular 18 from older versions of angular? like angular 16 to angular 18, for example. I've tried doing it and there are always so many errors, problems with installed libraries because of versions support, etc., plus, the older versions of angular managed all components as a non-standalone, so everything went into a app.module.ts huge file with all services, components, custom pipes, etc. With no configuration for hydration and what not, so how is it done? :( I'd really appreaciate it! and i'm sure a lot of people will too!
      thank you so much for all your work!

    • @ZoaibKhan
      @ZoaibKhan  5 หลายเดือนก่อน +1

      Well, a little secret: I had to record this video multiple times, because the first time I made a lot of mistakes which would've caused a lot of confusion. But that's just the process all of us creators have to go through :)
      Thanks for the subscribe and I hope you find more value here. About your suggestions, that is another frequently asked topic. And the only reason I haven't yet created a video on upgrade guide to latest version is because of its complexity. I recently upgraded one of my client's apps to the newest version - and from upgrading material to standalone to routing/state and third party libraries - it can get messy pretty quickly.
      But I've it in my list of todos - and hopefully will get to create one soon. I have an older chat app in Angular - maybe that would be a good cast study to follow for an upgrade to the latest version :)

    • @lshadowSFX
      @lshadowSFX 5 หลายเดือนก่อน

      @@ZoaibKhan I can tell you put a lot of effort into the videos! It makes it really pleasant to watch and listen to! thank you very much!

  • @brianm2029
    @brianm2029 หลายเดือนก่อน

    Thanks for the great content. Just to contribute and suggest that you can make a nested nav item recursively by calling the nav-item again if there are child items, but add the right inputs to the component to control its behavior and rendering. You can add a level as input and other relevant info as inputs. Thanks

  • @rohitkharche7562
    @rohitkharche7562 5 หลายเดือนก่อน

    I was scouting internet for this implementation and then found you uploaded video about it, thanks for this. Would love a similar with material 3 as well.

    • @ZoaibKhan
      @ZoaibKhan  5 หลายเดือนก่อน

      You're welcome 🤗 About material 3, it's going to change the look and feel of the sidebar a bit, so I'm not sure. Currently it is mimicking the TH-cam studio sidebar

  • @macgideons4201
    @macgideons4201 15 ชั่วโมงที่ผ่านมา

    Super Excellent.. if you click on content it shows content , but when you click on video, you still see content page and video page together. is there a way to route to video or playlist without content page also been displayed? Thanks

  • @sley007
    @sley007 21 วันที่ผ่านมา

    Excellent!

    • @ZoaibKhan
      @ZoaibKhan  21 วันที่ผ่านมา +1

      Glad you liked it!

  • @studenckimediator9513
    @studenckimediator9513 หลายเดือนก่อน

    Thank you so much! You helped me a lot!

    • @ZoaibKhan
      @ZoaibKhan  หลายเดือนก่อน

      Welcome, glad it helped :)

  • @swatisharma4241
    @swatisharma4241 13 วันที่ผ่านมา

    I didn’t use stand-alone so it is possible to imports all modules u define in ts file I import them in angular module ts

  • @yellaiahg9366
    @yellaiahg9366 2 หลายเดือนก่อน

    Thanks for the information.
    Please provide multiple sub menus handling.
    Example: If we select one menu, showing all submenus.

    • @ZoaibKhan
      @ZoaibKhan  2 หลายเดือนก่อน

      Can you elaborate that a bit? You mean expand all nested menus at once?

  • @tgrannan
    @tgrannan หลายเดือนก่อน

    I've been scratching my head on sub-menus for a few days, this really helped! What do you think it would take to make the parent just open to the children and not have it's own page? The example would be when you click on 'Content' instead of going to the content page it would just open the children. When you click on a child it would behave like it does now. Would love to get your thoughts on this.

    • @ZoaibKhan
      @ZoaibKhan  หลายเดือนก่อน

      It shouldn't be that hard and others have requested this as well, so I might do it in a video for everyone.
      Basic thing will be to have a null or empty route in content in menu items array. Then if it's empty, we can simply disable the router link on that item in some way.

  • @DirtySouth33T
    @DirtySouth33T 4 หลายเดือนก่อน

    great videos, i guess i am using a differnet version of material and things have changed a bit, what version should i be using for this video and the original ones?

    • @ZoaibKhan
      @ZoaibKhan  4 หลายเดือนก่อน

      It's using angular material 2 - which is default UpTo angular v17. From v18 onwards, it's material 3

  • @MahmoudTarek-pz1rl
    @MahmoudTarek-pz1rl 18 วันที่ผ่านมา

    Thanks a lot for the great content and effort.
    I just wonder why, for the nested menu item, you didn't use MatExpansionPanel component ?

    • @ZoaibKhan
      @ZoaibKhan  18 วันที่ผ่านมา

      It's not meant for that purpose and also would've taken lot more time to customize the styling to match the sidebar style.
      Also, it'd have made it more difficult to make it recursive - as I did in the next video in this series.

    • @MahmoudTarek-pz1rl
      @MahmoudTarek-pz1rl 17 วันที่ผ่านมา

      @ZoaibKhan I've done something similar using ngTemplateOutlet for recursion and the expansion panel for nested items. The problem was that I had to override many styles, especially for the expansion.
      And have a problem controlling which panel to open if a nested link is active
      Your approach is much simpler, and animation is totally customizable.
      Most of the time, sidebar components have to be more customizable and fit every need possible.
      Thanks a lot for your great work

    • @ZoaibKhan
      @ZoaibKhan  17 วันที่ผ่านมา

      @@MahmoudTarek-pz1rl thanks Mahmoud! My sidebar is still quite simple. Have you seen the new shadcn sidebar component? That is truly remarkable

    • @MahmoudTarek-pz1rl
      @MahmoudTarek-pz1rl 17 วันที่ผ่านมา

      @ZoaibKhan You're welcome,
      Simple but have a good potential and fulfil many requirements,
      Yes, I've seen it on the day of releas, and it is on another level
      The approach he follows is really great. I hope we can have a similar package for angular.
      Maybe one day Spartan UI will do it as they say

  • @informer9261
    @informer9261 5 หลายเดือนก่อน +1

    sir please make an video of how to share data between in different siblings components and how to setup up architechture of an project when we start build apllication.

    • @ZoaibKhan
      @ZoaibKhan  5 หลายเดือนก่อน

      Ok, those are common issues, so I've noted them for future videos.

  • @BatmunkhD
    @BatmunkhD 3 หลายเดือนก่อน

    Very useful, thanks. How to auto toggle/expand less/.

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน +1

      Glad you found it useful! You mean you want to toggle the nested state programmatically from outside the component?

    • @BatmunkhD
      @BatmunkhD 3 หลายเดือนก่อน

      @@ZoaibKhanyes, automatically expand less when moving to other title.

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน +1

      Means on navigation? Hmm, that's interesting. We can handle that by listening to a Navigation event inside the sidenav, then simply making the nested signal false when that happens.

  • @GerardoRojasPacheco
    @GerardoRojasPacheco 4 หลายเดือนก่อน

    Excellent, thank you very much for your contribution, very clear and useful
    Please, how could I make the menu expand when I hover over it, something like adminlte

    • @GerardoRojasPacheco
      @GerardoRojasPacheco 4 หลายเดือนก่อน

      I found the solution and share it..:

    • @ZoaibKhan
      @ZoaibKhan  4 หลายเดือนก่อน +1

      Perfect! One improvement might be to delay the mouse out a bit and wait for the user to be truly out of the sidenav and then collapse it. To prevent mistakes...

  • @AidosOmurzakov
    @AidosOmurzakov 3 หลายเดือนก่อน

    Great job. content is super usefull
    can you show example when sidebar is collapsed and show subitems not as icons but show as a menu when hovering the main root icon show on the right menu with child icons routes

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน

      You mean like a popup nested menu?

    • @AidosOmurzakov
      @AidosOmurzakov 3 หลายเดือนก่อน

      @@ZoaibKhan yes

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน

      Hmm, hiding the subitems in collapsed state is easy, but creating a separate popup for those items can be a bit challenging. If I had to do it, I'd use the angular cdk overlay package to create a custom overlay and open and close on hover/hover out.

  • @youraccountissuspended
    @youraccountissuspended 2 หลายเดือนก่อน

    good video. can you make video how to use angular signal correctly pls. thx

    • @ZoaibKhan
      @ZoaibKhan  2 หลายเดือนก่อน

      Hey thanks 🙏 What about signals do you find confusing?

    • @youraccountissuspended
      @youraccountissuspended 2 หลายเดือนก่อน

      @@ZoaibKhan how to use signal with rest api crud and state management

  • @jerrylee9351
    @jerrylee9351 2 หลายเดือนก่อน

    Great video, many thanks for it, but i've a question:
    Is it possible, that the/one menu-item inform the custom-sidenav, which link is currently active?
    Background: I would like to put a red bar information on the left side too if the menu is collapsed but one sub item menu entry is active.

    • @ZoaibKhan
      @ZoaibKhan  2 หลายเดือนก่อน

      You're welcome :)
      You can check the exact paths option in router link active.
      angular.dev/api/router/IsActiveMatchOptions#paths

    • @jerrylee9351
      @jerrylee9351 2 หลายเดือนก่อน

      @@ZoaibKhan Many thanks for your answer.
      That seems to work if the top entry ('Content' in your example) has a route entry.
      In my case the top entry hasn't a route, it works only like a combobox (i hope you know what i mean). 🤔
      My idea was to use the rla.isActive flag (that works correct if i test it with '{{rls.isActive | json}}`) to set an output on which listen the custom-sidenav... 🤷‍♂

    • @ZoaibKhan
      @ZoaibKhan  2 หลายเดือนก่อน

      @@jerrylee9351 how about using an empty route on the top entry?

    • @jerrylee9351
      @jerrylee9351 2 หลายเดือนก่อน

      @@ZoaibKhan I already tried this, but it doesn't work too. The first/top entry is *always* selected.
      Related to your example in the video:
      I click on 'Videos' and then menu points 'Conent' and 'Videos' are selected. ✅
      I switch to 'Analytics'. This menu item is selected ✅, but the 'Content' item is still selected. ❌

    • @ZoaibKhan
      @ZoaibKhan  หลายเดือนก่อน

      It seems I'll have to add explicit support for non route menu items.

  • @nilpeshpatel1373
    @nilpeshpatel1373 2 หลายเดือนก่อน

    I think with simple tweak it can be for n level subitems

    • @ZoaibKhan
      @ZoaibKhan  2 หลายเดือนก่อน

      Yup, check out the followup video on recursive components!

  • @andresilveira8004
    @andresilveira8004 หลายเดือนก่อน

    How can I click the menuItem opening the subMenu but not changing the route? I want to change the route only if I click in the submenu itens. Is it possible?

    • @ZoaibKhan
      @ZoaibKhan  หลายเดือนก่อน

      You can keep the route as empty for that specific item and see what happens? That's a good idea for a feature though which I may add in near future

    • @andresilveira8004
      @andresilveira8004 หลายเดือนก่อน

      @@ZoaibKhan I already tried it. The route turns to "undifined" like "localhost:3000/undefined/subMenuItem". Waiting for a future video about it :)

  • @imohanreddy
    @imohanreddy 5 หลายเดือนก่อน

    Hi , you are using function call menuItems() for iterating , which is a function is it optimal? as angular will have verify and update everytime irrespective of menuItems array changing?

    • @ZoaibKhan
      @ZoaibKhan  5 หลายเดือนก่อน

      It is a signal, Mohan! Signal values are accessed just like you're calling a function. As we move forward with the new changes in Angular and Zoneless apps, using signals in templates is the recommended approach!

    • @imohanreddy
      @imohanreddy 5 หลายเดือนก่อน

      @@ZoaibKhan oh , Thanks for the clarification 🙌

  • @dcoding
    @dcoding 3 หลายเดือนก่อน

    please next vidio

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน +1

      It's in this playlist
      th-cam.com/play/PLHbz-DWIAPJC9QksAO1PHobAGXde3CgIz.html&si=7hyhPKUKbUUKf79h

  • @wams4103
    @wams4103 3 หลายเดือนก่อน

    Good evening Zoaib Khan ! Thank you for the usefull tutorials and clear explanation. So I worked on the four tutorial but not in a standalone. I separated component. Now then I face one error in nested tutorial. here the message I have : NG2: Type 'import("D:/AngularDataProjects/Dashboard1/src/app/components/custom-sidenav/custom-sidenav.component").MenuItem' is not assignable to type 'import("D:/AngularDataProjects/Dashboard1/src/app/components/menu-item/menu-item.component").MenuItem'.
    Types of property 'route' are incompatible.
    Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.
    src/app/components/custom-sidenav/custom-sidenav.component.html:15:20

    • @ZoaibKhan
      @ZoaibKhan  3 หลายเดือนก่อน

      Good evening to you too :) Your error seems to point to a problem with the route. If possible, could you show the routes code?

    • @wams4103
      @wams4103 3 หลายเดือนก่อน

      @@ZoaibKhan Good evening Dear Zoaib ! Thank you for your response. the issue was resolved. I really appreciated.