-
Notifications
You must be signed in to change notification settings - Fork 422
Expand file tree
/
Copy pathapp.module.ts
More file actions
167 lines (154 loc) · 6.76 KB
/
app.module.ts
File metadata and controls
167 lines (154 loc) · 6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import { NgModule, Inject } from '@angular/core';
import { RouterModule, PreloadAllModules } from '@angular/router';
import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { HttpModule, Http } from '@angular/http';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
import { TransferHttpCacheModule } from '@nguniversal/common';
import { ReactiveFormsModule } from '@angular/forms';
import { FormlyModule } from '@ngx-formly/core';
import { FormlyBootstrapModule } from '@ngx-formly/bootstrap';
import { Ng2BootstrapModule } from 'ngx-bootstrap';
// i18n support
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppComponent } from './app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { CircularJsonPipe } from './components/json-circ/json-circ.pipe';
import { CoverSlideModuleComponent } from './components/cover-slide-module/cover-slide-module.component';
import { HomeComponent } from './containers/home/home.component';
import { UsersComponent } from './containers/users/users.component';
import { UserDetailComponent } from './components/user-detail/user-detail.component';
import { CounterComponent } from './containers/counter/counter.component';
import { NotFoundComponent } from './containers/not-found/not-found.component';
import { NgxBootstrapComponent } from './containers/ngx-bootstrap-demo/ngx-bootstrap.component';
import { LinkService } from './shared/link.service';
import { UserService } from './shared/user.service';
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine';
export function createTranslateLoader(http: HttpClient, baseHref) {
// Temporary Azure hack
if (baseHref === null && typeof window !== 'undefined') {
baseHref = window.location.origin;
}
// i18n files are in `wwwroot/assets/`
return new TranslateHttpLoader(http, `${baseHref}/assets/i18n/`, '.json');
}
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
CounterComponent,
UsersComponent,
UserDetailComponent,
HomeComponent,
NotFoundComponent,
NgxBootstrapComponent,
CircularJsonPipe,
CoverSlideModuleComponent
],
imports: [
CommonModule,
BrowserModule.withServerTransition({
appId: 'my-app-id' // make sure this matches with your Server NgModule
}),
HttpClientModule,
TransferHttpCacheModule,
BrowserTransferStateModule,
FormsModule,
ReactiveFormsModule,
FormlyModule.forRoot(),
FormlyBootstrapModule,
Ng2BootstrapModule.forRoot(), // You could also split this up if you don't want the Entire Module imported
// i18n support
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient, [ORIGIN_URL]]
}
}),
// App Routing
RouterModule.forRoot([
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home', component: HomeComponent,
// *** SEO Magic ***
// We're using "data" in our Routes to pass in our <title> <meta> <link> tag information
// Note: This is only happening for ROOT level Routes, you'd have to add some additional logic if you wanted this for Child level routing
// When you change Routes it will automatically append these to your document for you on the Server-side
// - check out app.component.ts to see how it's doing this
data: {
title: 'Homepage',
meta: [{ name: 'description', content: 'This is an example Description Meta tag!' }],
links: [
{ rel: 'canonical', href: 'http://blogs.example.com/blah/nice' },
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/' }
]
}
},
{
path: 'counter', component: CounterComponent,
data: {
title: 'Counter',
meta: [{ name: 'description', content: 'This is an Counter page Description!' }],
links: [
{ rel: 'canonical', href: 'http://blogs.example.com/counter/something' },
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/counter' }
]
}
},
{
path: 'users', component: UsersComponent,
data: {
title: 'Users REST example',
meta: [{ name: 'description', content: 'This is User REST API example page Description!' }],
links: [
{ rel: 'canonical', href: 'http://blogs.example.com/chat/something' },
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/users' }
]
}
},
{
path: 'ngx-bootstrap', component: NgxBootstrapComponent,
data: {
title: 'Ngx-bootstrap demo!!',
meta: [{ name: 'description', content: 'This is an Demo Bootstrap page Description!' }],
links: [
{ rel: 'canonical', href: 'http://blogs.example.com/bootstrap/something' },
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/bootstrap-demo' }
]
}
},
{ path: 'lazy', loadChildren: './containers/lazy/lazy.module#LazyModule'},
{
path: '**', component: NotFoundComponent,
data: {
title: '404 - Not found',
meta: [{ name: 'description', content: '404 - Error' }],
links: [
{ rel: 'canonical', href: 'http://blogs.example.com/bootstrap/something' },
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/bootstrap-demo' }
]
}
}
], {
// Router options
useHash: false,
preloadingStrategy: PreloadAllModules,
initialNavigation: 'enabled'
})
],
providers: [
LinkService,
UserService,
TranslateModule
],
bootstrap: [AppComponent]
})
export class AppModuleShared {
}