Answer the question
In order to leave comments, you need to log in
How to correctly make a layout?
There is an Agular module. It has a ModuleLayoutComponent which contains the base layout as well as for displaying the components. Question: how can I slightly change the ModuleLayoutComponen so that, depending on the current URL, some elements are shown?
Module code
@NgModule({
declarations: [ModuleLayoutComponent],
imports: [
CommonModule,
RouterModule.forChild([{path: '', pathMatch: 'full', component: ModuleLayoutComponent, children: [
{path: '/order', component: OrderComponent},
{path: '/payment', component: PaymentComponent}
]}])
],
})
<header></header>
<div class="content">
<router-outlet></router-outlet>
</div>
<footer></footer>
Answer the question
In order to leave comments, you need to log in
For example like this:
constructor(private router: Router) { }
this.router.events
.subscribe( res => {
if (res instanceof NavigationEnd) {
this.currentUrl = res.urlAfterRedirects;
}
});
<ng-container *ngIf=currentUrl === 'какой-то url'
<button>Назад</button>
</ng-container>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question