Answer the question
In order to leave comments, you need to log in
Don't show menu from app.component.html in angular 2?
In general, the essence is this:
There is a project on Angular 2, several components have been added: home, page, login, etc., which are used for navigation (listing app.routing.ts below:
import { Routes } from '@angular/router';
// компоненты системы
import { LoginComponent } from './components/index';
import { HomeComponent } from './components/index';
import { pageComponent } from "./components/index";
// Контроль авторизации
import { AuthGuard } from './_guards/index';
export const appRoutes: Routes = [
{ path:
'',
component: HomeComponent ,
canActivate: [AuthGuard]
},
{ path:
'login',
component: LoginComponent
},
{ path:
'page',
component: pageComponent,
canActivate: [AuthGuard]
},
{ path:
'**',
redirectTo: ''
},
];
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a routerLink="/" routerLinkActive="active">Главная</a>
</li>
<li>
<a routerLink="/page" routerLinkActive="active">Страница 1</a>
</li>
</li>
<li>
<a routerLink="/login" routerLinkActive="active">Выход</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<!-- Begin page content -->
<div id="wrapper" class="container">
<router-outlet></router-outlet>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question