-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to Angular rc3, use Observables, replace in-memory api
- Loading branch information
Showing
15 changed files
with
137 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,25 @@ | ||
import { Component } from '@angular/core'; | ||
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated'; | ||
import { Component } from '@angular/core'; | ||
import { ROUTER_DIRECTIVES } from '@angular/router'; | ||
|
||
import { DashboardComponent } from './dashboard.component'; | ||
import { HeroesComponent } from './heroes.component'; | ||
import { HeroDetailComponent } from './hero-detail.component'; | ||
import { HeroService } from '../services/hero.service'; | ||
import { HeroService } from '../services/hero.service'; | ||
|
||
@Component({ | ||
directives: [ROUTER_DIRECTIVES], | ||
providers: [ | ||
ROUTER_PROVIDERS, | ||
HeroService, | ||
], | ||
selector: 'my-app', | ||
styleUrls: ['dist/css/component/app.component.css'], | ||
template: ` | ||
<h1>{{title}}</h1> | ||
<nav> | ||
<a [routerLink]="['Dashboard']">Dashboard</a> | ||
<a [routerLink]="['Heroes']">Heroes</a> | ||
<!--<a [routerLink]="['/crisis-center']">Crisis Center</a>--> | ||
<!--<a [routerLink]="['/dashboard']">Dashboard</a>--> | ||
<a [routerLink]="['/heroes']">Heroes</a> | ||
</nav> | ||
<router-outlet></router-outlet> | ||
`, | ||
}) | ||
|
||
@RouteConfig([ | ||
{ | ||
component: DashboardComponent, | ||
name: 'Dashboard', | ||
path: '/dashboard', | ||
useAsDefault: true, | ||
}, | ||
{ | ||
component: HeroDetailComponent, | ||
name: 'HeroDetail', | ||
path: '/detail/:id', | ||
}, | ||
{ | ||
component: HeroesComponent, | ||
name: 'Heroes', | ||
path: '/heroes', | ||
}, | ||
]) | ||
|
||
export class AppComponent { | ||
title = 'Tour of Heroes'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
// Imports for loading & configuring the in-memory web api | ||
import { provide } from '@angular/core'; | ||
import { XHRBackend } from '@angular/http'; | ||
|
||
import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api/core'; | ||
import { InMemoryDataService } from './services/in-memory-data.service'; | ||
|
||
// The usual bootstrapping imports | ||
import { bootstrap } from '@angular/platform-browser-dynamic'; | ||
import { HTTP_PROVIDERS } from '@angular/http'; | ||
|
||
import { AppComponent } from './components/app.component'; | ||
import { APP_ROUTER_PROVIDERS } from './routes/app.routes'; | ||
|
||
document.addEventListener("DOMContentLoaded", function(event) { | ||
// TODO: register HTTP_PROVIDERS in AppComponent providers | ||
bootstrap(AppComponent, [ | ||
APP_ROUTER_PROVIDERS, | ||
HTTP_PROVIDERS, | ||
provide(XHRBackend, { useClass: InMemoryBackendService }), // in-mem server | ||
provide(SEED_DATA, { useClass: InMemoryDataService }), // in-mem server data | ||
]); | ||
]) | ||
.catch(err => console.error(err)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { provideRouter, RouterConfig } from '@angular/router'; | ||
|
||
import { DashboardComponent } from '../components/dashboard.component'; | ||
import { HeroesListComponent } from '../components/heroes-list.component'; | ||
import { HeroDetailComponent } from '../components/hero-detail.component'; | ||
|
||
|
||
export const routes: RouterConfig = [ | ||
// { path: 'crisis-center', component: CrisisCenterComponent }, | ||
{ | ||
component: DashboardComponent, | ||
path: '', | ||
}, | ||
{ | ||
component: HeroDetailComponent, | ||
path: 'detail/:id', | ||
}, | ||
{ | ||
component: HeroesListComponent, | ||
path: 'heroes', | ||
}, | ||
]; | ||
|
||
export const APP_ROUTER_PROVIDERS = [ | ||
provideRouter(routes), | ||
]; |
Oops, something went wrong.