• DEVHIDE
    • Home (current)
    • About
    • Contact
    • Cookie
    • Home (current)
    • About
    • Contact
    • Cookie
    • Disclaimer
    • Privacy
    • TOS
    Login Or Sign up

    Bootstrap list activating both menu in angular 13 on selecting

    2.1k Views Asked by chethan At 08 April 2022 at 08:46 2025-12-19T17:05:16.146000

    enter image description here

    enter image description here

    <ul class="nav">        
        <li class="nav-item" *ngFor="let menu of menuList">
    
          <a class="nav-link" href="index.html" *ngIf="menu.subMenu?.length<1">
            <i class="icon-grid menu-icon"></i>
            <span class="menu-title">{{menu.title}}</span>
          </a>
    
          <a class="nav-link"  *ngIf="menu.subMenu?.length>0" data-toggle="collapse"
             href="#ui-basic" aria-expanded="false" aria-controls="ui-basic">
            <i class="icon-layout menu-icon"></i>
            <span class="menu-title">{{menu.title}}</span>
            <i class="menu-arrow"></i>
          </a>
          <div class="collapse" id="ui-basic" *ngIf="menu.subMenu?.length>0">
            <ul class="nav flex-column sub-menu">
              <li class="nav-item" *ngFor="let sub of menu.subMenu">
                <a class="nav-link">
                  {{sub.title}}
                </a>
              </li>              
            </ul>
          </div>
        </li>
      </ul>
    
    
       export const SideBarMenu = [
         {
        id: 'dashboard',
        title: 'Dashboard',
        icon: 'icon-grid menu-icon',
        url: '',
      },
      {
        id: 'task',
        title: 'Task',
        icon: 'icon-layout menu-icon',
        url: '',
        subMenu: [
          {
            id: 'task1',
            title: 'Task 1',
            icon: '',
            url: '',
           },
          {
            id: 'task2',
            title: 'Task 2',
            icon: '',
            url: '',
          },
        ],
      },
      {
        id: 'scheduler',
        title: 'Scheduler',
        icon: 'icon-layout menu-icon',
        url: '',
        subMenu: [
          {
            id: 'calendar',
            title: 'Calendar',
            icon: '',
            url: '',
           },
           {
            id: 'scheduler',
            title: 'Scheduler',
            icon: '',
            url: '',
          },
          {
            id: 'orders',
            title: 'Orders',
            icon: '',
            url: '',
           },
           {
            id: 'users',
            title: 'Users',
            icon: '',
            url: '',
           },
           {
            id: 'sales',
            title: 'Sales',
            icon: '',
            url: '',
           },
         ],
       },
     ];
    

    Hi, I have created bootstrap sidebar here if i click on list its activating other menu also (please refer image 2) how to solve this . sorry if you don't understand question please refer image for clarification .

    i am using ngFor loop to display all the sidebar menu if i select any one menu its also activating other menu also please help me to find the solution.

    css angular bootstrap-4 angular13
    Original Q&A
    1

    There are 1 best solutions below

    1
    alin0509 alin0509 On 08 April 2022 at 10:05 BEST ANSWER

    You should create unique ids for the menus something like this 'ui-basic'+index

    <ul class="nav">        
        <li class="nav-item" *ngFor="let menu of menuList; let index = index"">
          <a class="nav-link" href="index.html" *ngIf="menu.subMenu?.length<1">
            <i class="icon-grid menu-icon"></i>
            <span class="menu-title">{{menu.title}}</span>
          </a>
          <a class="nav-link"  *ngIf="menu.subMenu?.length>0" data-toggle="collapse"
             href="#ui-basic" aria-expanded="false" [aria-controls]="'ui-basic'+index">
            <i class="icon-layout menu-icon"></i>
            <span class="menu-title">{{menu.title}}</span>
            <i class="menu-arrow"></i>
          </a>
          <div class="collapse" [id]="'ui-basic'+index" *ngIf="menu.subMenu?.length>0">
            <ul class="nav flex-column sub-menu">
              <li class="nav-item" *ngFor="let sub of menu.subMenu">
                <a class="nav-link">
                  {{sub.title}}
                </a>
              </li>              
            </ul>
          </div>
        </li>
      </ul>
    

    Related Questions in CSS

    • CSS Class is not applying to element (border width,color,and style attributes)
    • How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
    • Positioning child at bottom of parent with scroll
    • Play multiple audio files in a slider
    • How to set text over image?
    • Website zoomed out on Android default browser
    • Writing/Overwriting to specific XML file from ASP.NET code behind
    • My navbar is not expanding after collapse
    • when a checkbox is checked how to display a different hidden element using javascript
    • Gaps Vertically Using Dividers
    • CSS: Preventing a property to affect on element until the end of transition
    • Polygon Button with pure CSS
    • transform-origin doesnt apply in safari
    • show/hide multiple div tags at once and change the size of the remaining div tag
    • Mask the image/maps/div (circle) using css and jquery

    Related Questions in ANGULAR

    • Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
    • Module '"angular2/angular2"' has no exported member 'For'
    • import syntax in typescript creating another js file in visual studio
    • Separate ts file for imports
    • How to use an AngularJS 2 component multiple times in the same page?
    • injectables not working in angular 2.0 latest build 26
    • Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
    • Import {} from location is not found in VS Code using TypeScript and Angular 2
    • Angular 2/Typescript: require not found
    • ng-switch in Angular2
    • Angular 2 import issue: "Zone already exported on window the object!"
    • How to make FileReader work with Angular2?
    • Writing the most basic Unit test in Angular 2?
    • Angular2: Creating child components programmatically
    • AngularJS - TypeError: Cannot read property 'canonicalUrl' of undefined

    Related Questions in BOOTSTRAP-4

    • How to remove these margins between my Bootstrap 4 links?
    • Float nav items to the right in Bootstrap 4?
    • What does offset do in Bootstrap 4?
    • Webpack: Bootstrap-loader is not able to find installed bootstrap 4 module
    • Angular 2 - how to use scss with bootstrap 4 in testing using webpack
    • Angular, Bootstrap 4, angular-cli - where to place dependent scss and import it?
    • Bootstrap 4 -- branding + navbar items
    • bootstrap 4 feedback text doesnt render properly
    • Bootstrap 4: How to make top fixed navbar stay in container and not stretch?
    • 4 column responsive in Bootstrap
    • Bootstrap 4 Dropdown not working
    • Change Bootstrap 4 tooltip template without refresh
    • Multi-item carousel bootstrap 4
    • Vertical alignment in Bootstrap 4
    • Align navbar toggle button to the right

    Related Questions in ANGULAR13

    • How can i apply code before an element is erased by an *ngIf in Angular 13?
    • <input autocomplete="off" this is not working i am using in angular 13. still is showing lastPass.. in my input filed
    • angular13: how to manually add scss files by condition to index.html?
    • Error: Module build failed | Angular13: ck-editor postcss-loader error
    • reduce same function call inside ngFor loop
    • Sticky footer doesn't work on angular application using a flex layout technique
    • How to remove multiple object from an array in angular 13
    • How to get multiple selected row index in the table in angular 13
    • How to get selected row index by checkbox in angular 13
    • What is best way to go about replacing 'deployUrl' in angular.json for v13?
    • How to I log in to a confidential keycloak server from Angular 13?
    • Should .angular cache folder add to .dockerignore?
    • Alignment in Expansion Panel of Angular Material
    • ngx-source-obfuscation with Angular 13
    • Angular: Setting a date field by dropdown menu's selection

    Trending Questions

    • UIImageView Frame Doesn't Reflect Constraints
    • Is it possible to use adb commands to click on a view by finding its ID?
    • How to create a new web character symbol recognizable by html/javascript?
    • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
    • Heap Gives Page Fault
    • Connect ffmpeg to Visual Studio 2008
    • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
    • How to avoid default initialization of objects in std::vector?
    • second argument of the command line arguments in a format other than char** argv or char* argv[]
    • How to improve efficiency of algorithm which generates next lexicographic permutation?
    • Navigating to the another actvity app getting crash in android
    • How to read the particular message format in android and store in sqlite database?
    • Resetting inventory status after order is cancelled
    • Efficiently compute powers of X in SSE/AVX
    • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

    Popular # Hahtags

    javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

    Popular Questions

    • How do I undo the most recent local commits in Git?
    • How can I remove a specific item from an array in JavaScript?
    • How do I delete a Git branch locally and remotely?
    • Find all files containing a specific text (string) on Linux?
    • How do I revert a Git repository to a previous commit?
    • How do I create an HTML button that acts like a link?
    • How do I check out a remote Git branch?
    • How do I force "git pull" to overwrite local files?
    • How do I list all files of a directory?
    • How to check whether a string contains a substring in JavaScript?
    • How do I redirect to another webpage?
    • How can I iterate over rows in a Pandas DataFrame?
    • How do I convert a String to an int in Java?
    • Does Python have a string 'contains' substring method?
    • How do I check if a string contains a specific word?
    .

    Copyright © 2021 Jogjafile Inc.

    • Disclaimer
    • Privacy
    • TOS
    • Homegardensmart
    • Math
    • Aftereffectstemplates