docs(router): heavy copy edits (#3021)
|
@ -2,7 +2,8 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { PreloadSelectedModules } from '../selective-preload-strategy';
|
|
||||||
|
import { SelectivePreloadingStrategy } from '../selective-preloading-strategy';
|
||||||
|
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ export class AdminDashboardComponent implements OnInit {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private preloadStrategy: PreloadSelectedModules
|
private preloadStrategy: SelectivePreloadingStrategy
|
||||||
) {
|
) {
|
||||||
this.modules = preloadStrategy.preloadedModules;
|
this.modules = preloadStrategy.preloadedModules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { AdminDashboardComponent } from './admin-dashboard.component';
|
||||||
import { ManageCrisesComponent } from './manage-crises.component';
|
import { ManageCrisesComponent } from './manage-crises.component';
|
||||||
import { ManageHeroesComponent } from './manage-heroes.component';
|
import { ManageHeroesComponent } from './manage-heroes.component';
|
||||||
|
|
||||||
// #docregion admin-route
|
|
||||||
import { AuthGuard } from '../auth-guard.service';
|
import { AuthGuard } from '../auth-guard.service';
|
||||||
|
|
||||||
const adminRoutes: Routes = [
|
const adminRoutes: Routes = [
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
// #docregion
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
@ -22,7 +21,4 @@ import { AdminRoutingModule } from './admin-routing.module';
|
||||||
ManageHeroesComponent
|
ManageHeroesComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
// #docregion admin-module-export
|
|
||||||
export class AdminModule {}
|
export class AdminModule {}
|
||||||
// #enddocregion admin-module-export
|
|
||||||
// #enddocregion
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// #docregion
|
||||||
|
import { animate, AnimationEntryMetadata, state, style, transition, trigger } from '@angular/core';
|
||||||
|
|
||||||
|
// Component transition animations
|
||||||
|
export const slideInDownAnimation: AnimationEntryMetadata =
|
||||||
|
trigger('routeAnimation', [
|
||||||
|
state('*',
|
||||||
|
style({
|
||||||
|
opacity: 1,
|
||||||
|
transform: 'translateX(0)'
|
||||||
|
})
|
||||||
|
),
|
||||||
|
transition(':enter', [
|
||||||
|
style({
|
||||||
|
opacity: 0,
|
||||||
|
transform: 'translateX(-100%)'
|
||||||
|
}),
|
||||||
|
animate('0.2s ease-in')
|
||||||
|
]),
|
||||||
|
transition(':leave', [
|
||||||
|
animate('0.5s ease-out', style({
|
||||||
|
opacity: 0,
|
||||||
|
transform: 'translateY(100%)'
|
||||||
|
}))
|
||||||
|
])
|
||||||
|
]);
|
|
@ -1,17 +1,19 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
// #docregion
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
import { HeroListComponent } from './hero-list.component';
|
import { HeroListComponent } from './hero-list.component';
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
|
// #docregion appRoutes
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{ path: 'crisis-center', component: CrisisListComponent },
|
{ path: 'crisis-center', component: CrisisListComponent },
|
||||||
{ path: 'heroes', component: HeroListComponent },
|
{ path: 'heroes', component: HeroListComponent },
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
// #enddocregion appRoutes
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
// #docplaster
|
// #docplaster
|
||||||
// #docregion
|
// #docregion
|
||||||
|
// #docregion v2
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{ path: 'crisis-center', component: CrisisListComponent },
|
{ path: 'crisis-center', component: CrisisListComponent },
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,22 @@
|
||||||
// #docregion , v3
|
// #docregion , v3
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
// #enddocregion v3
|
// #enddocregion v3
|
||||||
|
// #docregion compose
|
||||||
{
|
{
|
||||||
path: 'compose',
|
path: 'compose',
|
||||||
component: ComposeMessageComponent,
|
component: ComposeMessageComponent,
|
||||||
outlet: 'modal'
|
outlet: 'popup'
|
||||||
}
|
},
|
||||||
|
// #enddocregion compose
|
||||||
// #docregion v3
|
// #docregion v3
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
// #docregion
|
// #docregion
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'compose',
|
path: 'compose',
|
||||||
component: ComposeMessageComponent,
|
component: ComposeMessageComponent,
|
||||||
outlet: 'modal'
|
outlet: 'popup'
|
||||||
}
|
},
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -6,26 +6,28 @@ import { RouterModule, Routes } from '@angular/router';
|
||||||
// #enddocregion import-router
|
// #enddocregion import-router
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
// #docregion can-load-guard
|
|
||||||
import { AuthGuard } from './auth-guard.service';
|
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
||||||
// #enddocregion can-load-guard
|
import { AuthGuard } from './auth-guard.service';
|
||||||
|
|
||||||
// #docregion lazy-load-admin, can-load-guard
|
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'compose',
|
path: 'compose',
|
||||||
component: ComposeMessageComponent,
|
component: ComposeMessageComponent,
|
||||||
outlet: 'modal'
|
outlet: 'popup'
|
||||||
},
|
},
|
||||||
|
// #docregion admin, admin-1
|
||||||
{
|
{
|
||||||
path: 'admin',
|
path: 'admin',
|
||||||
loadChildren: 'app/admin/admin.module#AdminModule',
|
loadChildren: 'app/admin/admin.module#AdminModule',
|
||||||
// #enddocregion lazy-load-admin
|
// #enddocregion admin-1
|
||||||
canLoad: [AuthGuard]
|
canLoad: [AuthGuard]
|
||||||
// #docregion lazy-load-admin
|
// #docregion admin-1
|
||||||
},
|
},
|
||||||
|
// #enddocregion admin, admin-1
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ import {
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
||||||
import { AuthGuard } from './auth-guard.service';
|
import { AuthGuard } from './auth-guard.service';
|
||||||
|
|
||||||
|
@ -16,33 +18,31 @@ const appRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'compose',
|
path: 'compose',
|
||||||
component: ComposeMessageComponent,
|
component: ComposeMessageComponent,
|
||||||
outlet: 'modal'
|
outlet: 'popup'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'admin',
|
path: 'admin',
|
||||||
loadChildren: 'app/admin/admin.module#AdminModule',
|
loadChildren: 'app/admin/admin.module#AdminModule',
|
||||||
canLoad: [AuthGuard]
|
canLoad: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
redirectTo: '/heroes',
|
|
||||||
pathMatch: 'full'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'crisis-center',
|
path: 'crisis-center',
|
||||||
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule'
|
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule'
|
||||||
},
|
},
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
// #docregion forRoot
|
||||||
RouterModule.forRoot(
|
RouterModule.forRoot(
|
||||||
appRoutes
|
appRoutes
|
||||||
// #enddocregion preload-v1
|
// #enddocregion preload-v1
|
||||||
, { preloadingStrategy: PreloadAllModules }
|
, { preloadingStrategy: PreloadAllModules }
|
||||||
// #docregion preload-v1
|
// #docregion preload-v1
|
||||||
)
|
)
|
||||||
|
// #enddocregion forRoot
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
RouterModule
|
RouterModule
|
||||||
|
|
|
@ -4,42 +4,39 @@ import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
import { CanDeactivateGuard } from './can-deactivate-guard.service';
|
||||||
import { AuthGuard } from './auth-guard.service';
|
import { AuthGuard } from './auth-guard.service';
|
||||||
import { PreloadSelectedModules } from './selective-preload-strategy';
|
import { SelectivePreloadingStrategy } from './selective-preloading-strategy';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'compose',
|
path: 'compose',
|
||||||
component: ComposeMessageComponent,
|
component: ComposeMessageComponent,
|
||||||
outlet: 'modal'
|
outlet: 'popup'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'admin',
|
path: 'admin',
|
||||||
loadChildren: 'app/admin/admin.module#AdminModule',
|
loadChildren: 'app/admin/admin.module#AdminModule',
|
||||||
canLoad: [AuthGuard]
|
canLoad: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
redirectTo: '/heroes',
|
|
||||||
pathMatch: 'full'
|
|
||||||
},
|
|
||||||
// #docregion preload-v2
|
// #docregion preload-v2
|
||||||
{
|
{
|
||||||
path: 'crisis-center',
|
path: 'crisis-center',
|
||||||
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule',
|
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule',
|
||||||
data: {
|
data: { preload: true }
|
||||||
preload: true
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
// #enddocregion preload-v2
|
// #enddocregion preload-v2
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forRoot(
|
RouterModule.forRoot(
|
||||||
appRoutes,
|
appRoutes,
|
||||||
{ preloadingStrategy: PreloadSelectedModules }
|
{ preloadingStrategy: SelectivePreloadingStrategy }
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
|
@ -47,7 +44,7 @@ const appRoutes: Routes = [
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CanDeactivateGuard,
|
CanDeactivateGuard,
|
||||||
PreloadSelectedModules
|
SelectivePreloadingStrategy
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {}
|
export class AppRoutingModule {}
|
||||||
|
|
|
@ -15,5 +15,4 @@ import { Component } from '@angular/core';
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent { }
|
||||||
}
|
|
||||||
|
|
|
@ -46,5 +46,4 @@ import { Router } from '@angular/router';
|
||||||
`
|
`
|
||||||
// #enddocregion template
|
// #enddocregion template
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent { }
|
||||||
}
|
|
||||||
|
|
|
@ -9,14 +9,15 @@ import { Component } from '@angular/core';
|
||||||
<nav>
|
<nav>
|
||||||
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
|
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
|
||||||
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
|
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
|
||||||
<a routerLink="/admin" routerLinkActive="active">Admin</a>
|
// #docregion contact-link
|
||||||
|
<a [routerLink]="[{ outlets: { popup: ['compose'] } }]">Contact</a>
|
||||||
|
// #enddocregion contact-link
|
||||||
</nav>
|
</nav>
|
||||||
|
// #docregion outlets
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
// #enddocregion template
|
<router-outlet name="popup"></router-outlet>
|
||||||
<router-outlet name="modal"></router-outlet>
|
// #enddocregion outlets
|
||||||
// #enddocregion template
|
|
||||||
`
|
`
|
||||||
// #enddocregion template
|
// #enddocregion template
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent { }
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// #docregion
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-app',
|
||||||
|
// #docregion template
|
||||||
|
template: `
|
||||||
|
<h1 class="title">Angular Router</h1>
|
||||||
|
<nav>
|
||||||
|
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
|
||||||
|
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
|
||||||
|
<a routerLink="/admin" routerLinkActive="active">Admin</a>
|
||||||
|
<a [routerLink]="[{ outlets: { popup: ['compose'] } }]">Contact</a>
|
||||||
|
</nav>
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
<router-outlet name="popup"></router-outlet>
|
||||||
|
`
|
||||||
|
// #enddocregion template
|
||||||
|
})
|
||||||
|
export class AppComponent { }
|
|
@ -12,10 +12,10 @@ import { Component } from '@angular/core';
|
||||||
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
|
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
|
||||||
<a routerLink="/admin" routerLinkActive="active">Admin</a>
|
<a routerLink="/admin" routerLinkActive="active">Admin</a>
|
||||||
<a routerLink="/login" routerLinkActive="active">Login</a>
|
<a routerLink="/login" routerLinkActive="active">Login</a>
|
||||||
<a [routerLink]="[{ outlets: { modal: ['compose'] } }]">Contact</a>
|
<a [routerLink]="[{ outlets: { popup: ['compose'] } }]">Contact</a>
|
||||||
</nav>
|
</nav>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
<router-outlet name="modal"></router-outlet>
|
<router-outlet name="popup"></router-outlet>
|
||||||
`
|
`
|
||||||
// #enddocregion template
|
// #enddocregion template
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,53 +1,41 @@
|
||||||
|
// NEVER USED. For docs only. Should compile though
|
||||||
// #docplaster
|
// #docplaster
|
||||||
// #docregion
|
|
||||||
// #docregion router-basics
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
|
||||||
import { HeroListComponent } from './hero-list.component';
|
import { HeroListComponent } from './hero-list.component';
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
import { PageNotFoundComponent } from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
import { PageNotFoundComponent as HeroDetailComponent } from './not-found.component';
|
import { PageNotFoundComponent as HeroDetailComponent } from './not-found.component';
|
||||||
import { PageNotFoundComponent as HomeComponent } from './not-found.component';
|
|
||||||
|
|
||||||
// #docregion route-config
|
// #docregion
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
// #docregion route-defs
|
|
||||||
// #docregion hero-detail-route
|
|
||||||
{ path: 'hero/:id', component: HeroDetailComponent },
|
|
||||||
// #enddocregion hero-detail-route
|
|
||||||
{ path: 'crisis-center', component: CrisisListComponent },
|
{ path: 'crisis-center', component: CrisisListComponent },
|
||||||
|
{ path: 'hero/:id', component: HeroDetailComponent },
|
||||||
{
|
{
|
||||||
path: 'heroes',
|
path: 'heroes',
|
||||||
component: HeroListComponent,
|
component: HeroListComponent,
|
||||||
data: {
|
data: { title: 'Heroes List' }
|
||||||
title: 'Heroes List'
|
},
|
||||||
}
|
{ path: '',
|
||||||
|
redirectTo: '/heroes',
|
||||||
|
pathMatch: 'full'
|
||||||
},
|
},
|
||||||
{ path: '', component: HomeComponent },
|
|
||||||
// #enddocregion route-defs
|
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
|
||||||
FormsModule,
|
|
||||||
RouterModule.forRoot(appRoutes)
|
RouterModule.forRoot(appRoutes)
|
||||||
|
// other imports here
|
||||||
],
|
],
|
||||||
declarations: [
|
|
||||||
AppComponent,
|
|
||||||
HeroListComponent,
|
|
||||||
HeroDetailComponent,
|
|
||||||
CrisisListComponent,
|
|
||||||
PageNotFoundComponent
|
|
||||||
],
|
|
||||||
bootstrap: [ AppComponent ]
|
|
||||||
})
|
|
||||||
// #enddocregion router-basics
|
|
||||||
export class AppModule {
|
|
||||||
}
|
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
/*
|
||||||
|
// #docregion
|
||||||
|
...
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
|
// #enddocregion
|
||||||
|
*/
|
||||||
|
})
|
||||||
|
export class AppModule0 { }
|
||||||
|
|
|
@ -12,16 +12,22 @@ import { AppComponent } from './app.component';
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
import { HeroListComponent } from './hero-list.component';
|
import { HeroListComponent } from './hero-list.component';
|
||||||
// #enddocregion first-config
|
// #enddocregion first-config
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
// #docregion first-config
|
// #docregion first-config
|
||||||
|
|
||||||
|
// #docregion appRoutes
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{ path: 'crisis-center', component: CrisisListComponent },
|
{ path: 'crisis-center', component: CrisisListComponent },
|
||||||
{ path: 'heroes', component: HeroListComponent },
|
{ path: 'heroes', component: HeroListComponent },
|
||||||
// #enddocregion first-config
|
// #enddocregion first-config
|
||||||
|
|
||||||
|
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
|
||||||
|
// #docregion wildcard
|
||||||
{ path: '**', component: PageNotFoundComponent }
|
{ path: '**', component: PageNotFoundComponent }
|
||||||
|
// #enddocregion wildcard
|
||||||
// #docregion first-config
|
// #docregion first-config
|
||||||
];
|
];
|
||||||
|
// #enddocregion appRoutes
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -39,6 +45,5 @@ const appRoutes: Routes = [
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
import { HeroListComponent } from './hero-list.component';
|
import { HeroListComponent } from './hero-list.component';
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -27,6 +27,5 @@ import { PageNotFoundComponent }from './not-found.component';
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
// #enddocregion hero-import
|
// #enddocregion hero-import
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
// #docregion
|
||||||
// #docregion hero-import
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { HeroesModule } from './heroes/heroes.module';
|
import { HeroesModule } from './heroes/heroes.module';
|
||||||
|
|
||||||
import { CrisisListComponent } from './crisis-list.component';
|
import { CrisisListComponent } from './crisis-list.component';
|
||||||
|
@ -27,7 +24,4 @@ import { PageNotFoundComponent } from './not-found.component';
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
// #enddocregion hero-import
|
export class AppModule { }
|
||||||
export class AppModule {
|
|
||||||
}
|
|
||||||
// #enddocregion
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { PageNotFoundComponent } from './not-found.component';
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { HeroesModule } from './heroes/heroes.module';
|
import { HeroesModule } from './heroes/heroes.module';
|
||||||
// #docregion crisis-center-module
|
// #docregion crisis-center-module
|
||||||
|
@ -34,14 +35,14 @@ import { DialogService } from './dialog.service';
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
// #enddocregion admin-module, crisis-center-module
|
// #enddocregion admin-module, crisis-center-module
|
||||||
ComposeMessageComponent
|
ComposeMessageComponent,
|
||||||
// #docregion admin-module, crisis-center-module
|
// #docregion admin-module, crisis-center-module
|
||||||
|
PageNotFoundComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DialogService
|
DialogService
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
|
@ -9,7 +9,9 @@ import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { HeroesModule } from './heroes/heroes.module';
|
import { HeroesModule } from './heroes/heroes.module';
|
||||||
import { CrisisCenterModule } from './crisis-center/crisis-center.module';
|
import { CrisisCenterModule } from './crisis-center/crisis-center.module';
|
||||||
|
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { AdminModule } from './admin/admin.module';
|
import { AdminModule } from './admin/admin.module';
|
||||||
import { DialogService } from './dialog.service';
|
import { DialogService } from './dialog.service';
|
||||||
|
@ -25,13 +27,12 @@ import { DialogService } from './dialog.service';
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
ComposeMessageComponent
|
ComposeMessageComponent,
|
||||||
|
PageNotFoundComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DialogService
|
DialogService
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
// #enddocregion
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { FormsModule } from '@angular/forms';
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
|
||||||
|
@ -17,12 +18,12 @@ const routes: Routes = [
|
||||||
RouterModule.forRoot(routes, { useHash: true }) // .../#/crisis-center/
|
RouterModule.forRoot(routes, { useHash: true }) // .../#/crisis-center/
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent
|
AppComponent,
|
||||||
|
PageNotFoundComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
|
|
|
@ -4,15 +4,14 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { PageNotFoundComponent }from './not-found.component';
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { HeroesModule } from './heroes/heroes.module';
|
import { HeroesModule } from './heroes/heroes.module';
|
||||||
import { CrisisCenterModule } from './crisis-center/crisis-center.module';
|
import { CrisisCenterModule } from './crisis-center/crisis-center.module';
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
|
|
||||||
import { LoginRoutingModule } from './login-routing.module';
|
import { LoginRoutingModule } from './login-routing.module';
|
||||||
import { LoginComponent } from './login.component';
|
import { LoginComponent } from './login.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { DialogService } from './dialog.service';
|
import { DialogService } from './dialog.service';
|
||||||
|
|
||||||
|
@ -28,12 +27,12 @@ import { DialogService } from './dialog.service';
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
ComposeMessageComponent,
|
ComposeMessageComponent,
|
||||||
LoginComponent
|
LoginComponent,
|
||||||
|
PageNotFoundComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DialogService
|
DialogService
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { PageNotFoundComponent } from './not-found.component';
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { HeroesModule } from './heroes/heroes.module';
|
import { HeroesModule } from './heroes/heroes.module';
|
||||||
import { ComposeMessageComponent } from './compose-message.component';
|
import { ComposeMessageComponent } from './compose-message.component';
|
||||||
import { LoginRoutingModule } from './login-routing.module';
|
import { LoginRoutingModule } from './login-routing.module';
|
||||||
import { LoginComponent } from './login.component';
|
import { LoginComponent } from './login.component';
|
||||||
|
import { PageNotFoundComponent } from './not-found.component';
|
||||||
|
|
||||||
import { DialogService } from './dialog.service';
|
import { DialogService } from './dialog.service';
|
||||||
|
|
||||||
|
@ -25,13 +25,12 @@ import { DialogService } from './dialog.service';
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
ComposeMessageComponent,
|
ComposeMessageComponent,
|
||||||
LoginComponent
|
LoginComponent,
|
||||||
|
PageNotFoundComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DialogService
|
DialogService
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule { }
|
||||||
}
|
|
||||||
// #enddocregion
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// #docplaster
|
// #docplaster
|
||||||
// #docregion, admin-can-load
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
CanActivate, Router,
|
CanActivate, Router,
|
||||||
|
@ -25,12 +24,13 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||||
return this.canActivate(route, state);
|
return this.canActivate(route, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #docregion, canLoad
|
||||||
canLoad(route: Route): boolean {
|
canLoad(route: Route): boolean {
|
||||||
let url = `/${route.path}`;
|
let url = `/${route.path}`;
|
||||||
|
|
||||||
return this.checkLogin(url);
|
return this.checkLogin(url);
|
||||||
}
|
}
|
||||||
// #enddocregion admin-can-load
|
// #enddocregion canLoad
|
||||||
|
|
||||||
checkLogin(url: string): boolean {
|
checkLogin(url: string): boolean {
|
||||||
if (this.authService.isLoggedIn) { return true; }
|
if (this.authService.isLoggedIn) { return true; }
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
|
||||||
// #docregion v1
|
|
||||||
import 'rxjs/add/observable/of';
|
|
||||||
import 'rxjs/add/operator/delay';
|
|
||||||
import 'rxjs/add/operator/do';
|
|
||||||
import { Component, HostBinding,
|
|
||||||
trigger, transition,
|
|
||||||
animate, style, state } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
template: `
|
|
||||||
<h3>Contact Crisis Center</h3>
|
|
||||||
<div *ngIf="details">
|
|
||||||
{{ details }}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<label>Message: </label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<textarea [(ngModel)]="message" rows="10" cols="35" [disabled]="sending"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p *ngIf="!sending">
|
|
||||||
<button (click)="send()">Send</button>
|
|
||||||
// #enddocregion v1
|
|
||||||
<button (click)="cancel()">Cancel</button>
|
|
||||||
// #docregion v1
|
|
||||||
</p>
|
|
||||||
`,
|
|
||||||
styles: [
|
|
||||||
`
|
|
||||||
:host {
|
|
||||||
position: relative;
|
|
||||||
bottom: 10%;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
],
|
|
||||||
animations: [
|
|
||||||
trigger('routeAnimation', [
|
|
||||||
state('*',
|
|
||||||
style({
|
|
||||||
opacity: 1,
|
|
||||||
transform: 'translateX(0)'
|
|
||||||
})
|
|
||||||
),
|
|
||||||
transition(':enter', [
|
|
||||||
style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}),
|
|
||||||
animate('0.2s ease-in')
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
animate('0.5s ease-out', style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export class ComposeMessageComponent {
|
|
||||||
@HostBinding('@routeAnimation') get routeAnimation() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.display') get display() {
|
|
||||||
return 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.position') get position() {
|
|
||||||
return 'absolute';
|
|
||||||
}
|
|
||||||
|
|
||||||
details: string;
|
|
||||||
sending: boolean = false;
|
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
|
||||||
|
|
||||||
send() {
|
|
||||||
this.sending = true;
|
|
||||||
this.details = 'Sending Message...';
|
|
||||||
|
|
||||||
Observable.of(true)
|
|
||||||
.delay(1000)
|
|
||||||
.do(() => {
|
|
||||||
this.sending = false;
|
|
||||||
// #enddocregion v1
|
|
||||||
this.closeModal();
|
|
||||||
// #docregion v1
|
|
||||||
}).subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
// #enddocregion v1
|
|
||||||
closeModal() {
|
|
||||||
this.router.navigate(['/', { outlets: { modal: null }}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel() {
|
|
||||||
this.closeModal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// #enddocregion
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- #docregion -->
|
||||||
|
<h3>Contact Crisis Center</h3>
|
||||||
|
<div *ngIf="details">
|
||||||
|
{{ details }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<label>Message: </label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<textarea [(ngModel)]="message" rows="10" cols="35" [disabled]="sending"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p *ngIf="!sending">
|
||||||
|
<button (click)="send()">Send</button>
|
||||||
|
<button (click)="cancel()">Cancel</button>
|
||||||
|
</p>
|
|
@ -1,77 +1,19 @@
|
||||||
// #docregion
|
// #docregion
|
||||||
import 'rxjs/add/observable/of';
|
import { Component, HostBinding } from '@angular/core';
|
||||||
import 'rxjs/add/operator/delay';
|
|
||||||
import 'rxjs/add/operator/do';
|
|
||||||
import { Component, HostBinding,
|
|
||||||
trigger, transition,
|
|
||||||
animate, style, state } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { slideInDownAnimation } from './animations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
moduleId: module.id,
|
||||||
<h3>Contact Crisis Center</h3>
|
templateUrl: 'compose-message.component.html',
|
||||||
<div *ngIf="details">
|
styles: [ ':host { position: relative; bottom: 10%; }' ],
|
||||||
{{ details }}
|
animations: [ slideInDownAnimation ]
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<label>Message: </label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<textarea [(ngModel)]="message" rows="10" cols="35" [disabled]="sending"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p *ngIf="!sending">
|
|
||||||
<button (click)="send()">Send</button>
|
|
||||||
<button (click)="cancel()">Cancel</button>
|
|
||||||
</p>
|
|
||||||
`,
|
|
||||||
styles: [
|
|
||||||
`
|
|
||||||
:host {
|
|
||||||
position: relative;
|
|
||||||
bottom: 10%;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
],
|
|
||||||
animations: [
|
|
||||||
trigger('routeAnimation', [
|
|
||||||
state('*',
|
|
||||||
style({
|
|
||||||
opacity: 1,
|
|
||||||
transform: 'translateX(0)'
|
|
||||||
})
|
|
||||||
),
|
|
||||||
transition(':enter', [
|
|
||||||
style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}),
|
|
||||||
animate('0.2s ease-in')
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
animate('0.5s ease-out', style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class ComposeMessageComponent {
|
export class ComposeMessageComponent {
|
||||||
@HostBinding('@routeAnimation') get routeAnimation() {
|
@HostBinding('@routeAnimation') routeAnimation = true;
|
||||||
return true;
|
@HostBinding('style.display') display = 'block';
|
||||||
}
|
@HostBinding('style.position') position = 'absolute';
|
||||||
|
|
||||||
@HostBinding('style.display') get display() {
|
|
||||||
return 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.position') get position() {
|
|
||||||
return 'absolute';
|
|
||||||
}
|
|
||||||
|
|
||||||
details: string;
|
details: string;
|
||||||
sending: boolean = false;
|
sending: boolean = false;
|
||||||
|
@ -82,24 +24,21 @@ export class ComposeMessageComponent {
|
||||||
this.sending = true;
|
this.sending = true;
|
||||||
this.details = 'Sending Message...';
|
this.details = 'Sending Message...';
|
||||||
|
|
||||||
Observable.of(true)
|
setTimeout(() => {
|
||||||
.delay(1000)
|
|
||||||
.do(() => {
|
|
||||||
this.sending = false;
|
this.sending = false;
|
||||||
|
this.closePopup();
|
||||||
// Close the modal
|
}, 1000);
|
||||||
this.closeModal();
|
|
||||||
}).subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
closeModal() {
|
|
||||||
// Providing a `null` value to the named outlet
|
|
||||||
// clears the contents of the named outlet
|
|
||||||
this.router.navigate([{ outlets: { modal: null }}]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
// Close the modal
|
this.closePopup();
|
||||||
this.closeModal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #docregion closePopup
|
||||||
|
closePopup() {
|
||||||
|
// Providing a `null` value to the named outlet
|
||||||
|
// clears the contents of the named outlet
|
||||||
|
this.router.navigate([{ outlets: { popup: null }}]);
|
||||||
|
}
|
||||||
|
// #enddocregion closePopup
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ import { CrisisDetailComponent } from './crisis-detail.component';
|
||||||
// #docregion can-deactivate-guard
|
// #docregion can-deactivate-guard
|
||||||
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
||||||
// #enddocregion can-deactivate-guard
|
// #enddocregion can-deactivate-guard
|
||||||
// #docregion crisis-detail-resolve
|
// #docregion crisis-detail-resolver
|
||||||
import { CrisisDetailResolve } from './crisis-detail-resolve.service';
|
import { CrisisDetailResolver } from './crisis-detail-resolver.service';
|
||||||
|
|
||||||
// #enddocregion crisis-detail-resolve
|
// #enddocregion crisis-detail-resolver
|
||||||
// #docregion routes
|
// #docregion routes
|
||||||
|
|
||||||
const crisisCenterRoutes: Routes = [
|
const crisisCenterRoutes: Routes = [
|
||||||
|
@ -43,11 +43,11 @@ const crisisCenterRoutes: Routes = [
|
||||||
// #docregion can-deactivate-guard
|
// #docregion can-deactivate-guard
|
||||||
canDeactivate: [CanDeactivateGuard],
|
canDeactivate: [CanDeactivateGuard],
|
||||||
// #enddocregion can-deactivate-guard
|
// #enddocregion can-deactivate-guard
|
||||||
// #docregion crisis-detail-resolve
|
// #docregion crisis-detail-resolver
|
||||||
resolve: {
|
resolve: {
|
||||||
crisis: CrisisDetailResolve
|
crisis: CrisisDetailResolver
|
||||||
}
|
}
|
||||||
// #enddocregion crisis-detail-resolve
|
// #enddocregion crisis-detail-resolver
|
||||||
// #docregion routes
|
// #docregion routes
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,9 +10,10 @@ import { CrisisDetailComponent } from './crisis-detail.component';
|
||||||
|
|
||||||
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
||||||
|
|
||||||
// #docregion crisis-detail-resolve
|
// #docregion crisis-detail-resolver
|
||||||
import { CrisisDetailResolve } from './crisis-detail-resolve.service';
|
import { CrisisDetailResolver } from './crisis-detail-resolver.service';
|
||||||
|
|
||||||
|
// #enddocregion crisis-detail-resolver
|
||||||
const crisisCenterRoutes: Routes = [
|
const crisisCenterRoutes: Routes = [
|
||||||
// #docregion redirect
|
// #docregion redirect
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,7 @@ const crisisCenterRoutes: Routes = [
|
||||||
component: CrisisDetailComponent,
|
component: CrisisDetailComponent,
|
||||||
canDeactivate: [CanDeactivateGuard],
|
canDeactivate: [CanDeactivateGuard],
|
||||||
resolve: {
|
resolve: {
|
||||||
crisis: CrisisDetailResolve
|
crisis: CrisisDetailResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -47,6 +48,7 @@ const crisisCenterRoutes: Routes = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// #docregion crisis-detail-resolver
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild(crisisCenterRoutes)
|
RouterModule.forChild(crisisCenterRoutes)
|
||||||
|
@ -55,8 +57,9 @@ const crisisCenterRoutes: Routes = [
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CrisisDetailResolve
|
CrisisDetailResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CrisisCenterRoutingModule { }
|
export class CrisisCenterRoutingModule { }
|
||||||
|
// #enddocregion crisis-detail-resolver
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
|
@ -9,9 +9,7 @@ import { CrisisCenterComponent } from './crisis-center.component';
|
||||||
import { CrisisDetailComponent } from './crisis-detail.component';
|
import { CrisisDetailComponent } from './crisis-detail.component';
|
||||||
|
|
||||||
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
import { CanDeactivateGuard } from '../can-deactivate-guard.service';
|
||||||
|
import { CrisisDetailResolver } from './crisis-detail-resolver.service';
|
||||||
// #docregion crisis-detail-resolve
|
|
||||||
import { CrisisDetailResolve } from './crisis-detail-resolve.service';
|
|
||||||
|
|
||||||
const crisisCenterRoutes: Routes = [
|
const crisisCenterRoutes: Routes = [
|
||||||
{
|
{
|
||||||
|
@ -27,7 +25,7 @@ const crisisCenterRoutes: Routes = [
|
||||||
component: CrisisDetailComponent,
|
component: CrisisDetailComponent,
|
||||||
canDeactivate: [CanDeactivateGuard],
|
canDeactivate: [CanDeactivateGuard],
|
||||||
resolve: {
|
resolve: {
|
||||||
crisis: CrisisDetailResolve
|
crisis: CrisisDetailResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -48,7 +46,7 @@ const crisisCenterRoutes: Routes = [
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CrisisDetailResolve
|
CrisisDetailResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CrisisCenterRoutingModule { }
|
export class CrisisCenterRoutingModule { }
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { CrisisCenterRoutingModule } from './crisis-center-routing.module';
|
||||||
providers: [
|
providers: [
|
||||||
CrisisService
|
CrisisService
|
||||||
]
|
]
|
||||||
// #enddocregion crisis-detail-resolve
|
// #enddocregion crisis-detail-resolver
|
||||||
})
|
})
|
||||||
// #docregion crisis-center-module-export
|
// #docregion crisis-center-module-export
|
||||||
export class CrisisCenterModule {}
|
export class CrisisCenterModule {}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { Router, Resolve, RouterStateSnapshot,
|
||||||
import { Crisis, CrisisService } from './crisis.service';
|
import { Crisis, CrisisService } from './crisis.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CrisisDetailResolve implements Resolve<Crisis> {
|
export class CrisisDetailResolver implements Resolve<Crisis> {
|
||||||
constructor(private cs: CrisisService, private router: Router) {}
|
constructor(private cs: CrisisService, private router: Router) {}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<Crisis> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<Crisis> {
|
|
@ -1,16 +1,14 @@
|
||||||
// #docplaster
|
// #docplaster
|
||||||
// #docregion
|
// #docregion
|
||||||
import 'rxjs/add/operator/switchMap';
|
import 'rxjs/add/operator/switchMap';
|
||||||
import { Component, OnInit,
|
import { Component, OnInit, HostBinding } from '@angular/core';
|
||||||
HostBinding, trigger, transition,
|
|
||||||
animate, style, state } from '@angular/core';
|
|
||||||
import { ActivatedRoute, Router, Params } from '@angular/router';
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
|
|
||||||
|
import { slideInDownAnimation } from '../animations';
|
||||||
import { Crisis, CrisisService } from './crisis.service';
|
import { Crisis, CrisisService } from './crisis.service';
|
||||||
import { DialogService } from '../dialog.service';
|
import { DialogService } from '../dialog.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
// #docregion template
|
|
||||||
template: `
|
template: `
|
||||||
<div *ngIf="crisis">
|
<div *ngIf="crisis">
|
||||||
<h3>"{{ editName }}"</h3>
|
<h3>"{{ editName }}"</h3>
|
||||||
|
@ -26,50 +24,17 @@ import { DialogService } from '../dialog.service';
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
// #enddocregion template
|
|
||||||
styles: ['input {width: 20em}'],
|
styles: ['input {width: 20em}'],
|
||||||
animations: [
|
animations: [ slideInDownAnimation ]
|
||||||
trigger('routeAnimation', [
|
|
||||||
state('*',
|
|
||||||
style({
|
|
||||||
opacity: 1,
|
|
||||||
transform: 'translateX(0)'
|
|
||||||
})
|
|
||||||
),
|
|
||||||
transition(':enter', [
|
|
||||||
style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateX(-100%)'
|
|
||||||
}),
|
|
||||||
animate('0.2s ease-in')
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
animate('0.5s ease-out', style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
// #docregion cancel-save
|
|
||||||
export class CrisisDetailComponent implements OnInit {
|
export class CrisisDetailComponent implements OnInit {
|
||||||
@HostBinding('@routeAnimation') get routeAnimation() {
|
@HostBinding('@routeAnimation') routeAnimation = true;
|
||||||
return true;
|
@HostBinding('style.display') display = 'block';
|
||||||
}
|
@HostBinding('style.position') position = 'absolute';
|
||||||
|
|
||||||
@HostBinding('style.display') get display() {
|
|
||||||
return 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.position') get position() {
|
|
||||||
return 'absolute';
|
|
||||||
}
|
|
||||||
|
|
||||||
crisis: Crisis;
|
crisis: Crisis;
|
||||||
editName: string;
|
editName: string;
|
||||||
|
|
||||||
// #enddocregion cancel-save
|
|
||||||
constructor(
|
constructor(
|
||||||
private service: CrisisService,
|
private service: CrisisService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -92,7 +57,6 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
}
|
}
|
||||||
// #enddocregion ngOnInit
|
// #enddocregion ngOnInit
|
||||||
|
|
||||||
// #docregion cancel-save
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.gotoCrises();
|
this.gotoCrises();
|
||||||
}
|
}
|
||||||
|
@ -101,9 +65,7 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
this.crisis.name = this.editName;
|
this.crisis.name = this.editName;
|
||||||
this.gotoCrises();
|
this.gotoCrises();
|
||||||
}
|
}
|
||||||
// #enddocregion cancel-save
|
|
||||||
|
|
||||||
// #docregion cancel-save-only
|
|
||||||
canDeactivate(): Promise<boolean> | boolean {
|
canDeactivate(): Promise<boolean> | boolean {
|
||||||
// Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
|
// Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
|
||||||
if (!this.crisis || this.crisis.name === this.editName) {
|
if (!this.crisis || this.crisis.name === this.editName) {
|
||||||
|
@ -113,9 +75,7 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
// promise which resolves to true or false when the user decides
|
// promise which resolves to true or false when the user decides
|
||||||
return this.dialogService.confirm('Discard changes?');
|
return this.dialogService.confirm('Discard changes?');
|
||||||
}
|
}
|
||||||
// #enddocregion cancel-save-only
|
|
||||||
|
|
||||||
// #docregion gotoCrises, relative-navigation
|
|
||||||
gotoCrises() {
|
gotoCrises() {
|
||||||
let crisisId = this.crisis ? this.crisis.id : null;
|
let crisisId = this.crisis ? this.crisis.id : null;
|
||||||
// Pass along the crisis id if available
|
// Pass along the crisis id if available
|
||||||
|
@ -124,8 +84,4 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
// Relative navigation back to the crises
|
// Relative navigation back to the crises
|
||||||
this.router.navigate(['../', { id: crisisId, foo: 'foo' }], { relativeTo: this.route });
|
this.router.navigate(['../', { id: crisisId, foo: 'foo' }], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
// #enddocregion gotoCrises, relative-navigation
|
|
||||||
// #docregion cancel-save
|
|
||||||
}
|
}
|
||||||
// #enddocregion cancel-save
|
|
||||||
// #enddocregion
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// #docplaster
|
// #docplaster
|
||||||
// #docregion
|
// #docregion
|
||||||
import { Component, OnInit, HostBinding,
|
import { Component, OnInit, HostBinding } from '@angular/core';
|
||||||
trigger, transition,
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
animate, style, state } from '@angular/core';
|
|
||||||
import { Router, ActivatedRoute } from '@angular/router';
|
|
||||||
|
|
||||||
|
import { slideInDownAnimation } from '../animations';
|
||||||
import { Crisis } from './crisis.service';
|
import { Crisis } from './crisis.service';
|
||||||
import { DialogService } from '../dialog.service';
|
import { DialogService } from '../dialog.service';
|
||||||
|
|
||||||
|
@ -25,43 +24,12 @@ import { DialogService } from '../dialog.service';
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
styles: ['input {width: 20em}'],
|
styles: ['input {width: 20em}'],
|
||||||
// #enddocregion template
|
animations: [ slideInDownAnimation ]
|
||||||
animations: [
|
|
||||||
trigger('routeAnimation', [
|
|
||||||
state('*',
|
|
||||||
style({
|
|
||||||
opacity: 1,
|
|
||||||
transform: 'translateX(0)'
|
|
||||||
})
|
|
||||||
),
|
|
||||||
transition(':enter', [
|
|
||||||
style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateX(-100%)'
|
|
||||||
}),
|
|
||||||
animate('0.2s ease-in')
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
animate('0.5s ease-out', style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class CrisisDetailComponent implements OnInit {
|
export class CrisisDetailComponent implements OnInit {
|
||||||
@HostBinding('@routeAnimation') get routeAnimation() {
|
@HostBinding('@routeAnimation') routeAnimation = true;
|
||||||
return true;
|
@HostBinding('style.display') display = 'block';
|
||||||
}
|
@HostBinding('style.position') position = 'absolute';
|
||||||
|
|
||||||
@HostBinding('style.display') get display() {
|
|
||||||
return 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.position') get position() {
|
|
||||||
return 'absolute';
|
|
||||||
}
|
|
||||||
|
|
||||||
crisis: Crisis;
|
crisis: Crisis;
|
||||||
editName: string;
|
editName: string;
|
||||||
|
@ -72,7 +40,7 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
public dialogService: DialogService
|
public dialogService: DialogService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// #docregion crisis-detail-resolve
|
// #docregion ngOnInit
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.data
|
this.route.data
|
||||||
.subscribe((data: { crisis: Crisis }) => {
|
.subscribe((data: { crisis: Crisis }) => {
|
||||||
|
@ -80,8 +48,9 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
this.crisis = data.crisis;
|
this.crisis = data.crisis;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// #enddocregion crisis-detail-resolve
|
// #enddocregion ngOnInit
|
||||||
|
|
||||||
|
// #docregion cancel-save
|
||||||
cancel() {
|
cancel() {
|
||||||
this.gotoCrises();
|
this.gotoCrises();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +59,9 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
this.crisis.name = this.editName;
|
this.crisis.name = this.editName;
|
||||||
this.gotoCrises();
|
this.gotoCrises();
|
||||||
}
|
}
|
||||||
|
// #enddocregion cancel-save
|
||||||
|
|
||||||
|
// #docregion canDeactivate
|
||||||
canDeactivate(): Promise<boolean> | boolean {
|
canDeactivate(): Promise<boolean> | boolean {
|
||||||
// Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
|
// Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
|
||||||
if (!this.crisis || this.crisis.name === this.editName) {
|
if (!this.crisis || this.crisis.name === this.editName) {
|
||||||
|
@ -100,8 +71,8 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
// promise which resolves to true or false when the user decides
|
// promise which resolves to true or false when the user decides
|
||||||
return this.dialogService.confirm('Discard changes?');
|
return this.dialogService.confirm('Discard changes?');
|
||||||
}
|
}
|
||||||
|
// #enddocregion canDeactivate
|
||||||
|
|
||||||
// #docregion gotoCrises
|
|
||||||
gotoCrises() {
|
gotoCrises() {
|
||||||
let crisisId = this.crisis ? this.crisis.id : null;
|
let crisisId = this.crisis ? this.crisis.id : null;
|
||||||
// Pass along the crisis id if available
|
// Pass along the crisis id if available
|
||||||
|
@ -112,5 +83,4 @@ export class CrisisDetailComponent implements OnInit {
|
||||||
this.router.navigate(['../', { id: crisisId, foo: 'foo' }], { relativeTo: this.route });
|
this.router.navigate(['../', { id: crisisId, foo: 'foo' }], { relativeTo: this.route });
|
||||||
// #enddocregion gotoCrises-navigate
|
// #enddocregion gotoCrises-navigate
|
||||||
}
|
}
|
||||||
// #enddocregion gotoCrises
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
|
||||||
import 'rxjs/add/operator/do';
|
import 'rxjs/add/operator/do';
|
||||||
import 'rxjs/add/operator/switchMap';
|
import 'rxjs/add/operator/switchMap';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
@ -9,28 +7,28 @@ import { Crisis, CrisisService } from './crisis.service';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
// #docregion template
|
// #docregion relative-navigation-router-link
|
||||||
template: `
|
template: `
|
||||||
<ul class="items">
|
<ul class="items">
|
||||||
<li *ngFor="let crisis of crises | async"
|
<li *ngFor="let crisis of crises | async">
|
||||||
(click)="onSelect(crisis)">
|
<a [routerLink]="[crisis.id]"
|
||||||
<span class="badge">{{ crisis.id }}</span> {{ crisis.name }}
|
[class.selected]="isSelected(crisis)">
|
||||||
|
<span class="badge">{{ crisis.id }}</span>
|
||||||
|
{{ crisis.name }}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>`
|
||||||
`,
|
// #enddocregion relative-navigation-router-link
|
||||||
// #enddocregion template
|
|
||||||
})
|
})
|
||||||
export class CrisisListComponent implements OnInit {
|
export class CrisisListComponent implements OnInit {
|
||||||
crises: Observable<Crisis[]>;
|
crises: Observable<Crisis[]>;
|
||||||
selectedId: number;
|
selectedId: number;
|
||||||
|
|
||||||
// #docregion relative-navigation-ctor
|
|
||||||
constructor(
|
constructor(
|
||||||
private service: CrisisService,
|
private service: CrisisService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
// #enddocregion relative-navigation-ctor
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.crises = this.route.params
|
this.crises = this.route.params
|
||||||
|
@ -40,17 +38,7 @@ export class CrisisListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #docregion select
|
isSelected(crisis: Crisis) {
|
||||||
onSelect(crisis: Crisis) {
|
return crisis.id === this.selectedId;
|
||||||
// Absolute link
|
|
||||||
this.router.navigate([crisis.id]);
|
|
||||||
}
|
}
|
||||||
// #enddocregion select
|
|
||||||
}
|
}
|
||||||
// #enddocregion
|
|
||||||
|
|
||||||
/*
|
|
||||||
// #docregion relative-navigation-router-link
|
|
||||||
<a [routerLink]="[crisis.id]">{{ crisis.name }}</a>
|
|
||||||
// #enddocregion relative-navigation-router-link
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// #docplaster
|
|
||||||
// #docregion
|
// #docregion
|
||||||
import 'rxjs/add/operator/switchMap';
|
import 'rxjs/add/operator/switchMap';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
@ -12,9 +11,10 @@ import { Crisis, CrisisService } from './crisis.service';
|
||||||
template: `
|
template: `
|
||||||
<ul class="items">
|
<ul class="items">
|
||||||
<li *ngFor="let crisis of crises | async"
|
<li *ngFor="let crisis of crises | async"
|
||||||
[class.selected]="isSelected(crisis)"
|
(click)="onSelect(crisis)"
|
||||||
(click)="onSelect(crisis)">
|
[class.selected]="isSelected(crisis)">
|
||||||
<span class="badge">{{ crisis.id }}</span> {{ crisis.name }}
|
<span class="badge">{{ crisis.id }}</span>
|
||||||
|
{{ crisis.name }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -25,11 +25,13 @@ export class CrisisListComponent implements OnInit {
|
||||||
crises: Observable<Crisis[]>;
|
crises: Observable<Crisis[]>;
|
||||||
selectedId: number;
|
selectedId: number;
|
||||||
|
|
||||||
|
// #docregion ctor
|
||||||
constructor(
|
constructor(
|
||||||
private service: CrisisService,
|
private service: CrisisService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
// #enddocregion ctor
|
||||||
|
|
||||||
isSelected(crisis: Crisis) {
|
isSelected(crisis: Crisis) {
|
||||||
return crisis.id === this.selectedId;
|
return crisis.id === this.selectedId;
|
||||||
|
@ -43,12 +45,12 @@ export class CrisisListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #docregion relative-navigation
|
// #docregion onSelect
|
||||||
onSelect(crisis: Crisis) {
|
onSelect(crisis: Crisis) {
|
||||||
this.selectedId = crisis.id;
|
this.selectedId = crisis.id;
|
||||||
|
|
||||||
// Navigate with relative link
|
// Navigate with relative link
|
||||||
this.router.navigate([crisis.id], { relativeTo: this.route });
|
this.router.navigate([crisis.id], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
// #enddocregion relative-navigation
|
// #enddocregion onSelect
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Component } from '@angular/core';
|
||||||
<h2>HEROES</h2>
|
<h2>HEROES</h2>
|
||||||
<p>Get your heroes here</p>
|
<p>Get your heroes here</p>
|
||||||
|
|
||||||
<button routerLink="/sidekicks">Go To Sidekicks</button>
|
<button routerLink="/sidekicks">Go to sidekicks</button>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class HeroListComponent { }
|
export class HeroListComponent { }
|
||||||
|
|
|
@ -2,17 +2,14 @@
|
||||||
// #docregion
|
// #docregion
|
||||||
// #docregion rxjs-operator-import
|
// #docregion rxjs-operator-import
|
||||||
import 'rxjs/add/operator/switchMap';
|
import 'rxjs/add/operator/switchMap';
|
||||||
// #docregion rxjs-operator-import
|
// #enddocregion rxjs-operator-import
|
||||||
// #docregion route-animation-imports
|
import { Component, OnInit, HostBinding } from '@angular/core';
|
||||||
import { Component, OnInit, HostBinding,
|
|
||||||
trigger, transition, animate,
|
|
||||||
style, state } from '@angular/core';
|
|
||||||
// #enddocregion route-animation-imports
|
|
||||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
|
|
||||||
|
import { slideInDownAnimation } from '../animations';
|
||||||
|
|
||||||
import { Hero, HeroService } from './hero.service';
|
import { Hero, HeroService } from './hero.service';
|
||||||
|
|
||||||
// #docregion route-animation
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
<h2>HEROES</h2>
|
<h2>HEROES</h2>
|
||||||
|
@ -29,44 +26,14 @@ import { Hero, HeroService } from './hero.service';
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
animations: [
|
animations: [ slideInDownAnimation ]
|
||||||
trigger('routeAnimation', [
|
|
||||||
state('*',
|
|
||||||
style({
|
|
||||||
opacity: 1,
|
|
||||||
transform: 'translateX(0)'
|
|
||||||
})
|
|
||||||
),
|
|
||||||
transition(':enter', [
|
|
||||||
style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateX(-100%)'
|
|
||||||
}),
|
|
||||||
animate('0.2s ease-in')
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
animate('0.5s ease-out', style({
|
|
||||||
opacity: 0,
|
|
||||||
transform: 'translateY(100%)'
|
|
||||||
}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
// #docregion route-animation-host-binding
|
|
||||||
export class HeroDetailComponent implements OnInit {
|
export class HeroDetailComponent implements OnInit {
|
||||||
// #enddocregion route-animation
|
// #docregion host-bindings
|
||||||
@HostBinding('@routeAnimation') get routeAnimation() {
|
@HostBinding('@routeAnimation') routeAnimation = true;
|
||||||
return true;
|
@HostBinding('style.display') display = 'block';
|
||||||
}
|
@HostBinding('style.position') position = 'absolute';
|
||||||
|
// #enddocregion host-bindings
|
||||||
@HostBinding('style.display') get display() {
|
|
||||||
return 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostBinding('style.position') get position() {
|
|
||||||
return 'absolute';
|
|
||||||
}
|
|
||||||
|
|
||||||
hero: Hero;
|
hero: Hero;
|
||||||
|
|
||||||
|
@ -87,14 +54,13 @@ export class HeroDetailComponent implements OnInit {
|
||||||
}
|
}
|
||||||
// #enddocregion ngOnInit
|
// #enddocregion ngOnInit
|
||||||
|
|
||||||
// #docregion gotoHeroes-navigate
|
// #docregion gotoHeroes
|
||||||
gotoHeroes() {
|
gotoHeroes() {
|
||||||
let heroId = this.hero ? this.hero.id : null;
|
let heroId = this.hero ? this.hero.id : null;
|
||||||
// Pass along the hero id if available
|
// Pass along the hero id if available
|
||||||
// so that the HeroList component can select that hero.
|
// so that the HeroList component can select that hero.
|
||||||
|
// Include a junk 'foo' property for fun.
|
||||||
this.router.navigate(['/heroes', { id: heroId, foo: 'foo' }]);
|
this.router.navigate(['/heroes', { id: heroId, foo: 'foo' }]);
|
||||||
}
|
}
|
||||||
// #enddocregion gotoHeroes-navigate
|
// #enddocregion gotoHeroes
|
||||||
// #docregion route-animation-host-binding
|
|
||||||
}
|
}
|
||||||
// #enddocregion route-animation-host-binding
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Hero, HeroService } from './hero.service';
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button routerLink="/sidekicks">Go To Sidekicks</button>
|
<button routerLink="/sidekicks">Go to sidekicks</button>
|
||||||
`
|
`
|
||||||
// #enddocregion template
|
// #enddocregion template
|
||||||
})
|
})
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { Hero, HeroService } from './hero.service';
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button routerLink="/sidekicks">Go To Sidekicks</button>
|
<button routerLink="/sidekicks">Go to sidekicks</button>
|
||||||
`
|
`
|
||||||
// #enddocregion template
|
// #enddocregion template
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: '<h2>Page not found</h2>'
|
||||||
<h2>Page Not Found</h2>
|
|
||||||
`
|
|
||||||
})
|
})
|
||||||
export class PageNotFoundComponent {}
|
export class PageNotFoundComponent {}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import { PreloadingStrategy, Route } from '@angular/router';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PreloadSelectedModules implements PreloadingStrategy {
|
export class SelectivePreloadingStrategy implements PreloadingStrategy {
|
||||||
preloadedModules: string[] = [];
|
preloadedModules: string[] = [];
|
||||||
|
|
||||||
preload(route: Route, load: Function): Observable<any> {
|
preload(route: Route, load: () => Observable<any>): Observable<any> {
|
||||||
if (route.data && route.data['preload']) {
|
if (route.data && route.data['preload']) {
|
||||||
// add the route path to our preloaded module array
|
// add the route path to our preloaded module array
|
||||||
this.preloadedModules.push(route.path);
|
this.preloadedModules.push(route.path);
|
|
@ -1,33 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<!-- #docregion -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<!-- #docregion base-href -->
|
|
||||||
<base href="/">
|
|
||||||
<!-- #enddocregion base-href -->
|
|
||||||
<title>Router Sample v.1</title>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link rel="stylesheet" href="styles.css">
|
|
||||||
|
|
||||||
<!-- Polyfills for older browsers -->
|
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
|
||||||
|
|
||||||
<script src="node_modules/zone.js/dist/zone.js"></script>
|
|
||||||
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
|
||||||
|
|
||||||
<script src="systemjs.config.js"></script>
|
|
||||||
<script>
|
|
||||||
System.import('app/main.1') // <----- ONLY CHANGE
|
|
||||||
.catch(function(err){ console.error(err); });
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Milestone 1</h1>
|
|
||||||
<my-app>loading...</my-app>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
<!-- #enddocregion -->
|
|
|
@ -3,7 +3,9 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- Set the base href -->
|
<!-- Set the base href -->
|
||||||
|
<!-- #docregion base-href -->
|
||||||
<base href="/">
|
<base href="/">
|
||||||
|
<!-- #enddocregion base-href -->
|
||||||
<title>Router Sample</title>
|
<title>Router Sample</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
"!**/*.js",
|
"!**/*.js",
|
||||||
"!**/*.[0-9].*",
|
"!**/*.[0-9].*",
|
||||||
"!app/crisis-list.component.ts",
|
"!app/crisis-list.component.ts",
|
||||||
"!app/hero-list.component.ts",
|
"!app/hero-list.component.ts"
|
||||||
"!app/crisis-center/add-crisis.component.ts",
|
|
||||||
"!app/not-found.component.ts"
|
|
||||||
],
|
],
|
||||||
"tags": ["router"]
|
"tags": ["router"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@ block includes
|
||||||
The Angular documentation is a living document with continuous improvements.
|
The Angular documentation is a living document with continuous improvements.
|
||||||
This log calls attention to recent significant changes.
|
This log calls attention to recent significant changes.
|
||||||
|
|
||||||
|
## Router: more detail (2016-12-21)
|
||||||
|
Added more information to the [Router](router.html) guide
|
||||||
|
including sections named outlets, wildcard routes, and preload strategies.
|
||||||
|
|
||||||
## Http: how to set default request headers (and other request options) (2016-12-14)
|
## Http: how to set default request headers (and other request options) (2016-12-14)
|
||||||
Added section on how to set default request headers (and other request options) to
|
Added section on how to set default request headers (and other request options) to
|
||||||
[Http](server-communication.html#override-default-request-options) guide.
|
[Http](server-communication.html#override-default-request-options) guide.
|
||||||
|
|
Before Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 228 KiB |