docs(aio): rename cb- files and a few others

This commit is contained in:
Ward Bell
2017-04-21 17:21:45 -07:00
committed by Pete Bacon Darwin
parent c3fa8803d3
commit 93516ea8a1
543 changed files with 467 additions and 510 deletions

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
import { HeroService } from './heroes';
@Component({
selector: 'sg-app',
template: '<toh-hero-list></toh-hero-list>',
providers: [HeroService]
})
export class AppComponent { }

View File

@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { HeroListComponent } from './heroes';
@NgModule({
imports: [
BrowserModule,
RouterModule.forChild([{ path: '05-15', component: AppComponent }])
],
declarations: [
AppComponent,
HeroListComponent
],
exports: [ AppComponent ]
})
export class AppModule {}

View File

@ -0,0 +1,39 @@
// #docregion
/* avoid */
import { OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/map';
import { Hero } from '../shared/hero.model';
const heroesUrl = 'http://angular.io';
export class HeroListComponent implements OnInit {
heroes: Hero[];
constructor(private http: Http) {}
getHeroes() {
this.heroes = [];
this.http.get(heroesUrl)
.map((response: Response) => <Hero[]>response.json().data)
.catch(this.catchBadResponse)
.finally(() => this.hideSpinner())
.subscribe((heroes: Hero[]) => this.heroes = heroes);
}
ngOnInit() {
this.getHeroes();
}
private catchBadResponse(err: any, source: Observable<any>) {
// log and handle the exception
return new Observable();
}
private hideSpinner() {
// hide the spinner
}
}

View File

@ -0,0 +1,23 @@
// #docregion example
import { Component, OnInit } from '@angular/core';
import { Hero, HeroService } from '../shared';
@Component({
selector: 'toh-hero-list',
template: `...`
})
export class HeroListComponent implements OnInit {
heroes: Hero[];
constructor(private heroService: HeroService) {}
getHeroes() {
this.heroes = [];
this.heroService.getHeroes()
.subscribe(heroes => this.heroes = heroes);
}
ngOnInit() {
this.getHeroes();
}
}
// #enddocregion example

View File

@ -0,0 +1 @@
export * from './hero-list.component';

View File

@ -0,0 +1,2 @@
export * from './hero-list';
export * from './shared';

View File

@ -0,0 +1,5 @@
// #docregion
export class Hero {
id: number;
name: string;
}

View File

@ -0,0 +1,15 @@
// #docregion
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { Hero } from './hero.model';
@Injectable()
export class HeroService {
getHeroes() {
let heroes: Hero[] = [];
return Observable.of(heroes);
}
}

View File

@ -0,0 +1,3 @@
// #docregion
export * from './hero.model';
export * from './hero.service';

View File

@ -0,0 +1,2 @@
export * from './heroes';
export * from './app.component';