Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(toh): update HTTP chapter with style guide conventions #1477

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions public/docs/_examples/toh-6/ts/app/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export class DashboardComponent implements OnInit {
heroes: Hero[] = [];

constructor(
private _router: Router,
private _heroService: HeroService) {
private router: Router,
private heroService: HeroService) {
}

ngOnInit() {
this._heroService.getHeroes()
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1,5));
}

gotoDetail(hero: Hero) {
let link = ['HeroDetail', { id: hero.id }];
this._router.navigate(link);
this.router.navigate(link);
}
}
15 changes: 8 additions & 7 deletions public/docs/_examples/toh-6/ts/app/hero-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// #docplaster
// #docregion
import { Component, Input, Output, OnInit, EventEmitter } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { RouteParams } from '@angular/router-deprecated';

import { Hero } from './hero';
import { HeroService } from './hero.service';

@Component({
selector: 'my-hero-detail',
templateUrl: 'app/hero-detail.component.html',
Expand All @@ -17,16 +18,16 @@ export class HeroDetailComponent implements OnInit {
navigated = false; // true if navigated here

constructor(
private _heroService: HeroService,
private _routeParams: RouteParams) {
private heroService: HeroService,
private routeParams: RouteParams) {
}

// #docregion ngOnInit
ngOnInit() {
if (this._routeParams.get('id') !== null) {
let id = +this._routeParams.get('id');
if (this.routeParams.get('id') !== null) {
let id = +this.routeParams.get('id');
this.navigated = true;
this._heroService.getHero(id)
this.heroService.getHero(id)
.then(hero => this.hero = hero);
} else {
this.navigated = false;
Expand All @@ -36,7 +37,7 @@ export class HeroDetailComponent implements OnInit {
// #enddocregion ngOnInit
// #docregion save
save() {
this._heroService
this.heroService
.save(this.hero)
.then(hero => {
this.hero = hero; // saved hero, w/ id if new
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-6/ts/app/hero.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #docplaster
// #docregion
import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import { Headers, Http } from '@angular/http';

// #docregion rxjs
import 'rxjs/add/operator/toPromise';
Expand Down
10 changes: 5 additions & 5 deletions public/docs/_examples/toh-6/ts/app/heroes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export class HeroesComponent implements OnInit {
error: any;

constructor(
private _router: Router,
private _heroService: HeroService) { }
private router: Router,
private heroService: HeroService) { }

getHeroes() {
this._heroService
this.heroService
.getHeroes()
.then(heroes => this.heroes = heroes)
.catch(error => this.error = error); // TODO: Display error message
Expand All @@ -46,7 +46,7 @@ export class HeroesComponent implements OnInit {
// #docregion delete
delete(hero: Hero, event: any) {
event.stopPropagation();
this._heroService
this.heroService
.delete(hero)
.then(res => {
this.heroes = this.heroes.filter(h => h !== hero);
Expand All @@ -66,6 +66,6 @@ export class HeroesComponent implements OnInit {
}

gotoDetail() {
this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]);
this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]);
}
}
2 changes: 1 addition & 1 deletion public/docs/ts/latest/tutorial/toh-pt6.jade
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ code-example(format="." language="bash").
:marked
### Save

We combine the call to the private `_post` and `_put` methods in a single `save` method. This simplifies the public api and makes the integration with `HeroDetailComponent` easier. `HeroService` determines which method to call based on the state of the `hero` object. If the hero already has an id we know it's an edit. Otherwise we know it's an add.
We combine the call to the private `post` and `put` methods in a single `save` method. This simplifies the public api and makes the integration with `HeroDetailComponent` easier. `HeroService` determines which method to call based on the state of the `hero` object. If the hero already has an id we know it's an edit. Otherwise we know it's an add.

+makeExample('toh-6/ts/app/hero.service.ts', 'save', 'app/hero.service.ts (save hero)')(format=".")

Expand Down