docs(aio): rename cb- files and a few others
This commit is contained in:

committed by
Pete Bacon Darwin

parent
c3fa8803d3
commit
93516ea8a1
@ -0,0 +1,6 @@
|
||||
<div>Actual favorite: {{favorite?.name}}</div>
|
||||
<ul>
|
||||
<li *ngFor="let hero of heroes">
|
||||
{{hero.name}}
|
||||
</li>
|
||||
</ul>
|
@ -0,0 +1,21 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { Hero, HeroService } from './heroes';
|
||||
import { ExceptionService, SpinnerService, ToastService } from './core';
|
||||
|
||||
@Component({
|
||||
selector: 'sg-app',
|
||||
templateUrl: './app.component.html',
|
||||
providers: [HeroService, ExceptionService, SpinnerService, ToastService]
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
favorite: Hero;
|
||||
heroes: Hero[];
|
||||
|
||||
constructor(private heroService: HeroService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.heroService.getHero(1).subscribe(hero => this.favorite = hero);
|
||||
this.heroService.getHeroes().subscribe(heroes => this.heroes = heroes);
|
||||
}
|
||||
}
|
17
aio/content/examples/styleguide/src/03-06/app/app.module.ts
Normal file
17
aio/content/examples/styleguide/src/03-06/app/app.module.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule.forChild([{ path: '03-06', component: AppComponent }])
|
||||
],
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
exports: [ AppComponent ]
|
||||
})
|
||||
export class AppModule {}
|
@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class ExceptionService { }
|
@ -0,0 +1,6 @@
|
||||
// #docregion
|
||||
// #docregion example
|
||||
export * from './exception.service';
|
||||
export * from './spinner';
|
||||
export * from './toast';
|
||||
// #enddocregion example
|
@ -0,0 +1,3 @@
|
||||
// #docregion
|
||||
export * from './spinner.component';
|
||||
export * from './spinner.service';
|
@ -0,0 +1,16 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { SpinnerService } from './spinner.service';
|
||||
|
||||
@Component({
|
||||
selector: 'toh-spinner',
|
||||
template: '<div>spinner</div>'
|
||||
})
|
||||
|
||||
export class SpinnerComponent implements OnDestroy, OnInit {
|
||||
constructor(private spinnerService: SpinnerService) { }
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
ngOnDestroy() { }
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface ISpinnerState { }
|
||||
|
||||
@Injectable()
|
||||
export class SpinnerService {
|
||||
spinnerState: any;
|
||||
|
||||
show() { }
|
||||
|
||||
hide() { }
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
// #docregion
|
||||
export * from './toast.component';
|
||||
export * from './toast.service';
|
@ -0,0 +1,13 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { ToastService } from './toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'toh-toast',
|
||||
template: '<div>toast</div>'
|
||||
})
|
||||
export class ToastComponent implements OnInit {
|
||||
constructor(toastService: ToastService) { }
|
||||
|
||||
ngOnInit() { }
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class ToastService {
|
||||
activate: (message?: string, title?: string) => void;
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './shared';
|
@ -0,0 +1,7 @@
|
||||
// #docregion
|
||||
// #docregion example
|
||||
export class Hero {
|
||||
name: string;
|
||||
power: string;
|
||||
}
|
||||
// #enddocregion example
|
@ -0,0 +1,32 @@
|
||||
// #docregion
|
||||
// #docregion example
|
||||
/* avoid */
|
||||
|
||||
import { ExceptionService, SpinnerService, ToastService } from '../../core';
|
||||
import { Http } from '@angular/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Hero } from './hero.model';
|
||||
// #enddocregion example
|
||||
|
||||
@Injectable()
|
||||
export class HeroService {
|
||||
|
||||
constructor(
|
||||
private exceptionService: ExceptionService,
|
||||
private spinnerService: SpinnerService,
|
||||
private toastService: ToastService,
|
||||
private http: Http
|
||||
) { }
|
||||
|
||||
getHero(id: number) {
|
||||
return this.http.get(`api/heroes/${id}`)
|
||||
.map(response => response.json().data as Hero);
|
||||
}
|
||||
|
||||
getHeroes() {
|
||||
return this.http.get(`api/heroes`)
|
||||
.map(response => response.json().data as Hero[]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
// #docregion
|
||||
// #docregion example
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
import { Hero } from './hero.model';
|
||||
import { ExceptionService, SpinnerService, ToastService } from '../../core';
|
||||
// #enddocregion example
|
||||
|
||||
@Injectable()
|
||||
export class HeroService {
|
||||
cachedHeroes: Hero[];
|
||||
|
||||
constructor(
|
||||
private exceptionService: ExceptionService,
|
||||
private spinnerService: SpinnerService,
|
||||
private toastService: ToastService,
|
||||
private http: Http
|
||||
) { }
|
||||
|
||||
getHero(id: number) {
|
||||
return this.http.get(`api/heroes/${id}`)
|
||||
.map(response => response.json().data as Hero);
|
||||
}
|
||||
|
||||
getHeroes() {
|
||||
return this.http.get(`api/heroes`)
|
||||
.map(response => response.json().data as Hero[]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
export * from './hero.model';
|
||||
export * from './hero.service';
|
3
aio/content/examples/styleguide/src/03-06/app/index.ts
Normal file
3
aio/content/examples/styleguide/src/03-06/app/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './heroes';
|
||||
export * from './core';
|
||||
export * from './app.component';
|
@ -0,0 +1,13 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { ToastService } from '../../core';
|
||||
|
||||
@Component({
|
||||
selector: 'toh-toast',
|
||||
template: '<div>toast</div>'
|
||||
})
|
||||
export class ToastComponent implements OnInit {
|
||||
constructor(toastService: ToastService) { }
|
||||
|
||||
ngOnInit() { }
|
||||
}
|
Reference in New Issue
Block a user