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

Commit ceda1c9

Browse files
johnpapawardbell
authored andcommitted
docs(style-guide): add style-guide - v.4
1 parent 3bc9414 commit ceda1c9

File tree

10 files changed

+212
-169
lines changed

10 files changed

+212
-169
lines changed

public/docs/_examples/style-guide/ts/01-01/app/app.component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
6-
// app.component.ts
2+
/**
3+
* The root AppComponent
4+
*/
75
import { Component, OnInit } from 'angular2/core';
86

9-
import { Hero } from './hero';
7+
import { Hero } from './hero.model';
108
import { HeroService } from './hero.service';
119

1210
@Component({
@@ -17,7 +15,7 @@ import { HeroService } from './hero.service';
1715
styleUrls: ['app/app.component.css'],
1816
providers: [HeroService]
1917
})
20-
export class AppComponent implements OnInit{
18+
export class AppComponent implements OnInit {
2119
heroes: Hero[] = [];
2220

2321
constructor(private heroService: HeroService) {}

public/docs/_examples/style-guide/ts/01-01/app/hero.model.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
2+
/**
3+
* The Hero Model
4+
*/
65
export class Hero {
76
id: number;
87
name: string;

public/docs/_examples/style-guide/ts/01-01/app/hero.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
2+
/**
3+
* The Data Access Service for heroes
4+
*/
65
import { Injectable } from 'angular2/core';
7-
import { HEROES } from './mock-heroes';
6+
import { HEROES } from './mock-heroes';
87

98
@Injectable()
109
export class HeroService {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// #docregion
2+
/**
3+
* Everything in one file ... it's all here!
4+
* AVOID THIS PATTERN
5+
*/
6+
import { bootstrap } from 'angular2/platform/browser';
7+
import { Component, OnInit } from 'angular2/core';
8+
9+
class Hero {
10+
id: number;
11+
name: string;
12+
}
13+
14+
@Component({
15+
selector: 'my-app',
16+
template: `
17+
<h1>{{title}}</h1>
18+
<pre>{{heroes | json}}</pre>
19+
`,
20+
styleUrls: ['app/app.component.css']
21+
})
22+
class AppComponent implements OnInit{
23+
title = 'Tour of Heroes';
24+
25+
heroes: Hero[] = [];
26+
27+
ngOnInit() {
28+
getHeroes().then(heroes => this.heroes = heroes);
29+
}
30+
}
31+
32+
bootstrap(AppComponent, []);
33+
34+
const HEROES: Hero[] = [
35+
{id: 1, name: 'Bombasto'},
36+
{id: 2, name: 'Tornado'},
37+
{id: 3, name: 'Magneta'},
38+
];
39+
40+
function getHeroes(): Promise<Hero[]> {
41+
return Promise.resolve(HEROES); // TODO: get hero data from the server;
42+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
6-
import { bootstrap } from 'angular2/platform/browser';
2+
/**
3+
* Application bootstrapping
4+
*/
5+
import { bootstrap } from 'angular2/platform/browser';
76
import { AppComponent } from './app.component';
87

98
bootstrap(AppComponent, []);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #docregion
2+
/**
3+
* Mock heroes until we can get real data
4+
*/
5+
import { Hero } from './hero.model';
6+
7+
export const HEROES: Hero[] = [
8+
{id: 1, name: 'Bombasto'},
9+
{id: 2, name: 'Tornado'},
10+
{id: 3, name: 'Magneta'},
11+
];

public/docs/_examples/style-guide/ts/01-01/app/placeholder.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)