Skip to content

Commit 39ffe26

Browse files
committed
Create shared module and layouts module
1 parent 8d60cfe commit 39ffe26

24 files changed

+700
-31
lines changed

.angular-cli.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"testTsconfig": "tsconfig.spec.json",
2121
"prefix": "app",
2222
"styles": [
23-
"styles.scss"
23+
"styles.scss",
24+
"styles/main.scss"
2425
],
2526
"scripts": [],
2627
"environmentSource": "environments/environment.ts",

src/app/app.component.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
<nav>
2-
<ul>
3-
<li><button (click)="changeLang('en')">EN</button></li>
4-
<li><button (click)="changeLang('ru')">RU</button></li>
5-
</ul>
6-
<ul>
7-
<li><a [routerLink]="['']" [routerLinkActive]="['router-link-active']">home</a></li>
8-
<li><a [routerLink]="['/mock']" [routerLinkActive]="['router-link-active']">mock</a></li>
9-
<li><a [routerLink]="['/back']" [routerLinkActive]="['router-link-active']">back http</a></li>
10-
</ul>
11-
</nav>
121
<router-outlet></router-outlet>

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { PageTitlePositioning } from '@ngx-meta/core';
1414
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
1515
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
1616
import { PrebootModule } from 'preboot';
17+
import { SharedModule } from '@shared/shared.module';
1718

1819
export function metaFactory(): MetaLoader {
1920
const setting: MetaSettings = {
@@ -50,6 +51,7 @@ export function httpLoaderFactory(http: HttpClient) {
5051
AppRoutes,
5152
TransferHttpModule,
5253
BrowserAnimationsModule,
54+
SharedModule.forRoot(),
5355
MetaModule.forRoot({
5456
provide: MetaLoader,
5557
useFactory: metaFactory,

src/app/app.routing.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import { Routes, RouterModule } from '@angular/router';
22
import { MetaGuard } from '@ngx-meta/core';
33

4+
import { WrapperComponent } from '@shared/layouts/wrapper/wrapper.component';
5+
46
const routes: Routes = [
57
{
6-
path: '', loadChildren: './home/home.module#HomeModule',
7-
data: {
8-
// for override default meta
9-
meta: {
10-
title: 'home title',
11-
override: true,
12-
description: 'home description'
13-
}
14-
},
15-
// need for default meta
16-
canActivateChild: [MetaGuard],
17-
},
18-
// without meta
19-
{ path: 'mock', loadChildren: './mock-server-browser/mock-server-browser.module#MockServerBrowserModule' },
20-
// with meta
21-
{ path: 'back', loadChildren: './transfer-back/transfer-back.module#TransferBackModule', canActivateChild: [MetaGuard]},
22-
// 404
23-
{ path: '404', loadChildren: './not-found/not-found.module#NotFoundModule' },
24-
{ path: '**', redirectTo: '404', pathMatch: 'full' }
8+
path: '', component: WrapperComponent, children: [
9+
{
10+
path: '', loadChildren: './home/home.module#HomeModule',
11+
data: {
12+
// for override default meta
13+
meta: {
14+
title: 'home title',
15+
override: true,
16+
description: 'home description'
17+
}
18+
},
19+
// need for default meta
20+
canActivateChild: [MetaGuard],
21+
},
22+
// without meta
23+
{ path: 'mock', loadChildren: './mock-server-browser/mock-server-browser.module#MockServerBrowserModule' },
24+
// with meta
25+
{ path: 'back', loadChildren: './transfer-back/transfer-back.module#TransferBackModule', canActivateChild: [MetaGuard] },
26+
// 404
27+
{ path: '**', loadChildren: './not-found/not-found.module#NotFoundModule' },
28+
]
29+
}
2530
];
2631
// must use {initialNavigation: 'enabled'}) - for one load page, without reload
2732
export const AppRoutes = RouterModule.forRoot(routes, { initialNavigation: 'enabled' });
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<ul>
2+
<li><button (click)="changeLang('en')">EN</button></li>
3+
<li><button (click)="changeLang('ru')">RU</button></li>
4+
</ul>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-footer',
5+
templateUrl: './footer.component.html'
6+
})
7+
export class FooterComponent {
8+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { RouterModule } from '@angular/router';
4+
5+
import { FooterComponent } from './footer/footer.component';
6+
import { SidebarComponent } from './sidebar/sidebar.component';
7+
import { ToolbarComponent } from './toolbar/toolbar.component';
8+
import { WrapperComponent } from './wrapper/wrapper.component';
9+
10+
@NgModule({
11+
imports: [
12+
CommonModule,
13+
RouterModule,
14+
],
15+
declarations: [
16+
FooterComponent,
17+
SidebarComponent,
18+
ToolbarComponent,
19+
WrapperComponent
20+
]
21+
})
22+
export class LayoutsModule {
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<nav>
2+
<ul>
3+
<li><a [routerLink]="['']" [routerLinkActive]="['router-link-active']">home</a></li>
4+
<li><a [routerLink]="['/mock']" [routerLinkActive]="['router-link-active']">mock</a></li>
5+
<li><a [routerLink]="['/back']" [routerLinkActive]="['router-link-active']">back http</a></li>
6+
</ul>
7+
</nav>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-sidebar',
5+
templateUrl: './sidebar.component.html'
6+
})
7+
export class SidebarComponent {
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span>Angular RU Universal Starter</span>

0 commit comments

Comments
 (0)