Skip to content

Commit 5230b34

Browse files
committed
Move routing examples into example project
1 parent b5f13b1 commit 5230b34

35 files changed

+28166
-146
lines changed

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
### Node ###
22

3-
# Demo
4-
/demo/netlify
5-
/demo/serverless.ts
6-
/demo/tsconfig.serverless.json
7-
/demo/_redirects
8-
/demo/node_modules
9-
103
# Logs
114
logs
125
*.log

demo/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/netlify
2+
/serverless.ts
3+
/tsconfig.serverless.json
4+
/_redirects
5+
/node_modules

demo/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
"@angular/platform-server": "~12.0.4",
2828
"@angular/router": "~12.0.4",
2929
"@netlify/functions": "^0.7.2",
30-
"@nguniversal/express-engine": "~12.0.1",
30+
"@nguniversal/express-engine": "^12.0.1",
3131
"adm-zip": "^0.5.5",
32+
"aws-serverless-express": "^3.4.0",
33+
"express": "^4.17.1",
3234
"rxjs": "~7.1.0",
3335
"tslib": "^2.2.0",
3436
"zone.js": "~0.11.4"

demo/src/app/app-routing.module.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
import { CommonModule } from '@angular/common'
2-
import { NgModule } from '@angular/core'
3-
import { RouterModule, Routes } from '@angular/router'
4-
import { HeroesComponent } from './heroes/heroes.component'
5-
import { DashboardComponent } from './dashboard/dashboard.component'
6-
import { HeroDetailComponent } from './hero-detail/hero-detail.component'
7-
import { NotFoundComponent } from './not-found/not-found.component'
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
import { HeroesComponent } from './heroes/heroes.component';
4+
import { DashboardComponent } from './dashboard/dashboard.component';
5+
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
86

97
const routes: Routes = [
108
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
119
{ path: 'dashboard', component: DashboardComponent },
1210
{ path: 'detail/:id', component: HeroDetailComponent },
1311
{ path: 'heroes', component: HeroesComponent },
14-
{ path: '**', component: NotFoundComponent },
15-
]
12+
];
1613

1714
@NgModule({
18-
imports: [
19-
CommonModule,
20-
RouterModule.forRoot(routes, {
21-
initialNavigation: 'enabled',
22-
}),
23-
],
15+
imports: [RouterModule.forRoot(routes, {
16+
initialNavigation: 'enabled'
17+
})],
2418
exports: [RouterModule],
25-
declarations: [DashboardComponent, HeroDetailComponent, HeroesComponent, NotFoundComponent],
2619
})
2720
export class AppRoutingModule {}

demo/src/app/app.module.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { NgModule } from '@angular/core'
2-
import { BrowserModule } from '@angular/platform-browser'
3-
import { FormsModule } from '@angular/forms'
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { FormsModule } from '@angular/forms';
44

5-
import { AppComponent } from './app.component'
6-
import { AppRoutingModule } from './app-routing.module'
7-
import { MessagesComponent } from './messages/messages.component'
5+
import { AppComponent } from './app.component';
6+
import { HeroesComponent } from './heroes/heroes.component';
7+
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
8+
import { MessagesComponent } from './messages/messages.component';
9+
import { AppRoutingModule } from './app-routing.module';
10+
import { DashboardComponent } from './dashboard/dashboard.component';
811

912
@NgModule({
10-
declarations: [AppComponent, MessagesComponent],
13+
declarations: [AppComponent, HeroesComponent, HeroDetailComponent, MessagesComponent, DashboardComponent],
1114
imports: [BrowserModule.withServerTransition({ appId: 'serverApp' }), FormsModule, AppRoutingModule],
1215
providers: [],
1316
bootstrap: [AppComponent],

demo/src/app/app.server.module.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { PlatformLocation } from '@angular/common'
2-
import { NgModule } from '@angular/core'
3-
import { ServerModule } from '@angular/platform-server'
1+
import { NgModule } from '@angular/core';
2+
import { ServerModule } from '@angular/platform-server';
43

5-
import { AppModule } from './app.module'
6-
import { AppComponent } from './app.component'
7-
import { ExpressRedirectPlatformLocation } from './express-redirect-platform-location.service'
4+
import { AppModule } from './app.module';
5+
import { AppComponent } from './app.component';
86

97
@NgModule({
10-
imports: [AppModule, ServerModule],
8+
imports: [
9+
AppModule,
10+
ServerModule,
11+
],
1112
bootstrap: [AppComponent],
12-
providers: [{ provide: PlatformLocation, useClass: ExpressRedirectPlatformLocation }],
1313
})
1414
export class AppServerModule {}

demo/src/app/express-redirect-platform-location.service.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

demo/src/app/not-found/not-found.component.spec.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
17+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

examples/advanced-routing/.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.sass-cache
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
npm-debug.log
39+
yarn-error.log
40+
testem.log
41+
/typings
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db
46+
47+
# Netlify
48+
/netlify
49+
/serverless.ts
50+
/tsconfig.serverless.json
51+
/_redirects

examples/advanced-routing/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Advanced Routing Example
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.1.3.
4+
5+
These steps have been run for setting it up:
6+
7+
```sh
8+
ng new angular-tour-of-heroes --minimal
9+
ng generate universal
10+
```
11+
12+
These parts have been added afterwards to demo advanced routing:
13+
- `src/app/express-redirect-platform-location.service.ts`
14+
- `src/app/not-found/`

0 commit comments

Comments
 (0)