jakob witsch
jakob witsch

Reputation: 161

Correct Routing in a tabbed modal in Angular

I created a modal using MatDialog. This Modal opens a component that has a tabbed page inside.

this.dialog.open(AuthComponent, dialogConfig);

I used the mat-tab-nav-bar to open the two tabbed components for Login and Register.

<nav mat-tab-nav-bar mat-align-tabs="center">
        <a mat-tab-link
           *ngFor="let link of navLinks"
           [routerLink]="link.path"
           routerLinkActive #rla="routerLinkActive"
           [active]="rla.isActive">
          {{link.label}}
        </a>
      </nav>

      <router-outlet></router-outlet>

To open the modal works fine, but the login component is not loaded when i open the modal. I first have to click on the link.

When i open the modal

"Click on Login"

locin clicked

My routing looks pretty straight forward:

{ path: 'signup', component: SignupComponent},

{ path: 'login',  component: LoginComponent},

Do you have any thoughts? Jakob

Upvotes: 1

Views: 1267

Answers (1)

Chellappan வ
Chellappan வ

Reputation: 27491

Try this:

export class AuthComponent implements OnInit {    

  constructor(private router: Router) {}

  ngOnInit() {
    this.router.navigate(['signup'])        
  }
}

Upvotes: 2

Related Questions