Danielle
Danielle

Reputation: 1496

this.router.navigateByUrl routing fine, but not displaying HTML content

I have my routes as follows:

 {path: 'login', component: LoginComponent},
  {path: 'platform', component: PlatformComponent,
    children: [
    ...
    ...

and app.component.html with just the following content:

<router-outlet></router-outlet>

and then on app.component.ts the following code at the constructor {}:

  this._router.navigateByUrl("/login");

After the user enters the email and password, if validated, Im doing

this.router.navigate(['../platform/maindashboard'], { relativeTo: this.activeRoute });

I also did

this.router.navigateByUrl("/platform/maindashboard");

but in both cases (even if Im being routed to the correct route) a blank page is displayed. I checked the HTML code on the page and its all there, but nothing is being rendered.

I've been dealing with this for hours already and I cannot find a solution to this.

Thanks so much.

Upvotes: 2

Views: 1088

Answers (2)

pvg1975
pvg1975

Reputation: 303

Do you have inside a div containing a class? Something like

<div class="wrapper">
   <router-outlet></router-outlet>
</div

Check deleting the class and see if it works.

Upvotes: 2

jagjeet
jagjeet

Reputation: 595

recently i had the same problem and it was solved by changing

{path: 'platform', component: PlatformComponent,
children: [
  {
    path: 'maindashboard',
    component: MainComponent
  }
...
...

to this

{path: 'platform',
    children: [
      {
        path: '',
        component: PlatformComponent
      },
      {
        path: 'maindashboard',
        component: MainComponent
      }
    ...
    ...

i don't really know the difference but it worked

Upvotes: 0

Related Questions