S
S
sdgroup142018-06-29 16:54:37
Angular
sdgroup14, 2018-06-29 16:54:37

How to pass empty to /en /ru route in Angular 2+?

Hello. I apologize if I didn't formulate the question correctly. But I don’t even know how it is correctly called by terms :). There is a project. There are pages, say 'domain.com/news/atricle12312'. I usually write like this:

{
    path: 'main',
    loadChildren: './pages/main/main.module#MainModule'
  },
  {
    path: 'news',
    loadChildren: './pages/news/news.module#NewsModule'
  },
  {
    path: 'confirmation',
    component: ConfirmationComponent
  },
  {
    path: '404',
    component: PageNotFoundComponent
  },
  {
    path: '',
    redirectTo: '/main',
    pathMatch: 'full'
  },
  {
    path: '**',
    redirectTo: '/404',
    pathMatch: 'full'
  }

];

But the task is this. that after the domain, the user can add the language 'domain.com/ru/news/atricle12312' through a slash,
how can I make it so that I don't get thrown at 404 after ru. And so that I can parse the url to pick up 'ru'. And how to make it so that if you enter 'ru' then pick up its value - specify a new default language in the service and so that the url becomes 'domain.com/news/atricle12312' but with the Russian language. Once again, I apologize if I didn’t formulate it well, but the idea should be clear

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Stroykin, 2018-06-29
@sdgroup14

I threw a mini example, I hope the concept will be clear - link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question