Click here to Skip to main content
14,695,085 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here, when user click on submenu I wanted parent menu to get "Active" class

I tried with
<pre><li  data-toggle="collapse" data-target="#products" routerLink="admintools" routerLinkActive="active" class="collapsed">


but its working when i click on submenu parent menu got "Active" class but i dont want user to redirect anywhere if user click on parent menu which is currently happening.

Routing as follows
const appRoutes: Routes = [
{
  path: 'admintools',children: [
    {
      path: 'approverconfig', children: [
        { path: '', redirectTo: 'user',pathMatch: 'full' },
        { path: 'user', component: UserConfigComponent },
        { path: 'process', component: ProcessConfigComponent }
      ]
    }
  ]
},

]

HTML code as follows
<pre><li  data-toggle="collapse" data-target="#products" routerLink="admintools" routerLinkActive="active" class="collapsed">
                  <a> Admin / Tools <span class="arrow"></span></a>
                </li>


                <ul class="sub-menu collapse" id="products">
                    <li routerLinkActive="active"><a routerLink="admintools/approverconfig">User Configuration</a></li>
                </ul>



What I have tried:

I tried
routerLink="admintools" routerLinkActive="active"
but user can able to click on parent menu also and locoation getting change
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900