Routes in Angular 5

0

Could you help me with the following?:

I have a sidebar in Angular that redirects me to a route ADMIN , this route has a daughter named STUDENTS . For when the user enters the ADMIN route, eh defined that a child route is automatically loaded, so that the user does not fall into a empty state

path: 'admin', component: DashAdminComponent, children: [
  { path: '', component: EstudiantesComponent, pathMatch: 'full' },
   { path: 'estudiantes', component: EstudiantesComponent}

this works correctly, however, although eh defined the [routerLinkActive]="class" attribute, the anchor does not receive the class:

<li class="text-center" routerLinkActive="active">
                <a [routerLink]="['estudiantes']">
                    <i class="fa fa-user fa-lg f_1rem"></i>
                    <a class="pb-0 pt-2 pl-3 pl-lg-0">
                        Estudiantes
                    </a>
                </a>
</li>

Only if I click on the anchor the [routerLinkActive] attribute has an effect, and I would like it to be applied together with the automatic redirection. I attach images to illustrate better. I appreciate any help and safety.

    
asked by Joel Muñoz Moran 22.07.2018 в 09:05
source

1 answer

0

You are not doing automatic redirection, you are saying that if the route is empty, show the EstudiantesComponent component. The redirection is done like this:

path: 'admin', component: DashAdminComponent, children: [
  { path: '', redirecTo: 'estudiantes', pathMatch: 'full' },
   { path: 'estudiantes', component: EstudiantesComponent}
    
answered by 22.07.2018 / 15:17
source