Angular route direct to folder with Wordpress

Asked

Viewed 37 times

1

My Angular application is at the root of the domain and I want when typing an empty route it redirects to /home, where in this folder I have Wordpress installed. That is to say always type only www.dominio.com the light route to /home where Wordpress is Installed.

my file of routes

export const ROUTES:Routes = [
 {
    path: 'home', component:PublicComponent,
    children: [            
      { path: },          
    ]
  },
  {
    path: 'clientnotfound',component:PublicComponent, 
    children: [            
      { path: '',component: PastaClienteComponent},

    ] 
  },       
  {
    path: 'confirmado',component:PublicComponent, 
    children: [            
      { path: ':id',component: CadastroFinalComponent},

    ] 
  },    


  // Main redirect
  {path: '', redirectTo: '/home', pathMatch: 'full'},  

  // Handle all other routes
  {path: '**',  redirectTo: '/clientnotfound'}
];

picture of the final directory

inserir a descrição da imagem aqui

  • But the {{ path: '', Component: Homecomponent }} didn’t work?

  • when the user type www.dominio.com it takes to home component (which does not contain wordpress), already when of type www.dominio.com/home it loads the wordpress that this in this folder, ignoring the route.

  • Could insert an image of how folders are arranged in the project?

1 answer

1


How do you have a route mapped to /home when you apply the redirect this route is called within the Angular context.

You can create a component and use window.localion.href= to return to your root DNS. Example:

export class ReComponent implements OnInit {
    ngOnInit() {
        window.location.href = 'www.dominio.com';
    }
}

// no arquivo de rotas:
{path: '', component: ReComponent }

It did not look very elegant but it solves the problem. As an alternative I found this article that shows something similar using a resolve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.