Colleagues hello.

I have a lot of components, I use a router and during route-redirection I ran into a problem, I will describe in detail:

I have one header file app.component.html it displays all the components in its entirety, I mean the site completely, but now I’ve made the component about using routera, when I clicked on it, to display everything I wrote in about.component.html, here a problem arises when I click on about, the about itself is displayed, but the site is also displayed along with it, that is, the title page + about and it is necessary that when you click, only what I recorded in about is displayed. enter image description here enter image description here

  • one
    Everything is so confusing. Can add code or structure? - Kostiantyn Okhotnyk
  • <navbar> </ navbar> <jumbotrone> </ jumbotrone> <div class = "container"> <router-outlet> </ router-outlet> </ div> I have this code in app.component.html and it displays everything correctly, but when I switch on about using a router and say, I have only one line about <h1> Hello World </ h1>, when I click on about, my hello world is displayed and the app.component.html structure itself, when clicking on about, only hello world without a structure was displayed. - user218635
  • one
    and the router? can add to the question the router and components that cause? - Kostiantyn Okhotnyk
  • Added, add something else? - user218635
  • for about there should be another page altogether? - Kostiantyn Okhotnyk

1 answer 1

Routing structure

{ path: 'home', component: BaseComponent, children: [ { path: '', component: HomeComponent } ] }, { path: 'about', component: AboutComponent }, 

in app.componet.html leave only

 <router-outlet></router-outlet> 

and in base.component.html will be what the app was

  • Something did not work out for me, please explain in more detail where I should create base.component.html, make another folder and make 2 files base.component.ts and html? - user218635
  • Yes everything is correct. Once created in the template, write the code that you had in the app component. - Kostiantyn Okhotnyk
  • What kind of mistakes do you get? - Kostiantyn Okhotnyk
  • I get nothing, white screen. But it is shown that successfully scamped? - user218635
  • You have a team viewer can climb and see? - user218635