From b2c2c3d359c8411b35ee933f832c963197abf735 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Mon, 16 May 2016 00:26:36 -0600 Subject: [PATCH 01/41] docs(cb-example): Add barrels cookbook docs --- .../docs/_examples/cb-barrels.huh/e2e-spec.js | 110 ++++++++++++++++++ .../cb-barrels.huh/ts/app/app.component.css | 28 +++++ .../cb-barrels.huh/ts/app/app.component.ts | 29 +++++ .../ts/app/dashboard.component.css | 60 ++++++++++ .../ts/app/dashboard.component.html | 8 ++ .../ts/app/dashboard.component.ts | 23 ++++ .../ts/app/heroes/hero-detail.component.css | 29 +++++ .../ts/app/heroes/hero-detail.component.html | 10 ++ .../ts/app/heroes/hero-detail.component.ts | 26 +++++ .../ts/app/heroes/hero.service.ts | 16 +++ .../cb-barrels.huh/ts/app/heroes/hero.ts | 4 + .../ts/app/heroes/heroes.component.css | 59 ++++++++++ .../ts/app/heroes/heroes.component.html | 14 +++ .../ts/app/heroes/heroes.component.ts | 30 +++++ .../cb-barrels.huh/ts/app/heroes/index.ts | 4 + .../_examples/cb-barrels.huh/ts/app/main.ts | 10 ++ .../cb-barrels.huh/ts/app/mock-heroes.ts | 14 +++ .../cb-barrels.huh/ts/example-config.json | 0 .../_examples/cb-barrels.huh/ts/index.html | 26 +++++ .../_examples/cb-barrels.huh/ts/plnkr.json | 8 ++ public/docs/_examples/cb-barrels/e2e-spec.js | 110 ++++++++++++++++++ .../cb-barrels/ts/app/app.component.css | 28 +++++ .../cb-barrels/ts/app/app.component.ts | 29 +++++ .../cb-barrels/ts/app/dashboard.component.css | 60 ++++++++++ .../ts/app/dashboard.component.html | 8 ++ .../cb-barrels/ts/app/dashboard.component.ts | 23 ++++ .../ts/app/heroes/hero-detail.component.css | 29 +++++ .../ts/app/heroes/hero-detail.component.html | 10 ++ .../ts/app/heroes/hero-detail.component.ts | 27 +++++ .../cb-barrels/ts/app/heroes/hero.service.ts | 16 +++ .../cb-barrels/ts/app/heroes/hero.ts | 4 + .../ts/app/heroes/heroes.component.css | 59 ++++++++++ .../ts/app/heroes/heroes.component.html | 14 +++ .../ts/app/heroes/heroes.component.ts | 30 +++++ .../cb-barrels/ts/app/heroes/index.ts | 4 + .../docs/_examples/cb-barrels/ts/app/main.ts | 10 ++ .../cb-barrels/ts/app/mock-heroes.ts | 14 +++ .../cb-barrels/ts/example-config.json | 0 .../docs/_examples/cb-barrels/ts/index.html | 26 +++++ .../docs/_examples/cb-barrels/ts/plnkr.json | 8 ++ public/docs/ts/latest/cookbook/_data.json | 5 + public/docs/ts/latest/cookbook/barrels.jade | 68 +++++++++++ 42 files changed, 1090 insertions(+) create mode 100644 public/docs/_examples/cb-barrels.huh/e2e-spec.js create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/app.component.css create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/main.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts create mode 100644 public/docs/_examples/cb-barrels.huh/ts/example-config.json create mode 100644 public/docs/_examples/cb-barrels.huh/ts/index.html create mode 100644 public/docs/_examples/cb-barrels.huh/ts/plnkr.json create mode 100644 public/docs/_examples/cb-barrels/e2e-spec.js create mode 100644 public/docs/_examples/cb-barrels/ts/app/app.component.css create mode 100644 public/docs/_examples/cb-barrels/ts/app/app.component.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/dashboard.component.css create mode 100644 public/docs/_examples/cb-barrels/ts/app/dashboard.component.html create mode 100644 public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.css create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.html create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/index.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/main.ts create mode 100644 public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts create mode 100644 public/docs/_examples/cb-barrels/ts/example-config.json create mode 100644 public/docs/_examples/cb-barrels/ts/index.html create mode 100644 public/docs/_examples/cb-barrels/ts/plnkr.json create mode 100644 public/docs/ts/latest/cookbook/barrels.jade diff --git a/public/docs/_examples/cb-barrels.huh/e2e-spec.js b/public/docs/_examples/cb-barrels.huh/e2e-spec.js new file mode 100644 index 0000000000..a109efb5a8 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/e2e-spec.js @@ -0,0 +1,110 @@ +describe('Tutorial', function () { + + beforeAll(function () { + browser.get(''); + }); + + function getPageStruct() { + hrefEles = element.all(by.css('my-app a')); + + return { + hrefs: hrefEles, + myDashboardHref: hrefEles.get(0), + myDashboardParent: element(by.css('my-app my-dashboard')), + topHeroes: element.all(by.css('my-app my-dashboard .module.hero')), + + myHeroesHref: hrefEles.get(1), + myHeroesParent: element(by.css('my-app my-heroes')), + allHeroes: element.all(by.css('my-app my-heroes li')), + + heroDetail: element(by.css('my-app my-hero-detail')) + } + } + + it('should be able to see the start screen', function () { + var page = getPageStruct(); + expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); + expect(page.myDashboardHref.getText()).toEqual("Dashboard"); + expect(page.myHeroesHref.getText()).toEqual("Heroes"); + }); + + it('should be able to see dashboard choices', function () { + var page = getPageStruct(); + expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices"); + }); + + it('should be able to toggle the views', function () { + var page = getPageStruct(); + + expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); + expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown"); + return page.myDashboardHref.click(); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); + }); + + }); + + it('should be able to edit details from "Dashboard" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); + var heroEle = page.topHeroes.get(3); + var heroDescrEle = heroEle.element(by.css('h4')); + var heroDescr; + return heroDescrEle.getText().then(function(text) { + heroDescr = text; + return heroEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-foo'); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); + expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); + }); + }); + + it('should be able to edit details from "Heroes" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); + var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); + var heroEle, heroDescr; + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); + heroEle = page.allHeroes.get(2); + return heroEle.getText(); + }).then(function(text) { + // remove leading 'id' from the element + heroDescr = text.substr(text.indexOf(' ')+1); + return heroEle.click(); + }).then(function() { + expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); + return viewDetailsButtonEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-bar'); + }).then(function() { + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); + expect(heroEle.getText()).toContain(heroDescr + '-bar'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); + }); + }); + + function editDetails(page, origValue, textToAdd) { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); + expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); + var inputEle = page.heroDetail.element(by.css('input')); + expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); + var backButtonEle = page.heroDetail.element(by.css('button')); + expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); + var detailTextEle = page.heroDetail.element(by.css('div h2')); + expect(detailTextEle.getText()).toContain(origValue); + return sendKeys(inputEle, textToAdd).then(function () { + expect(detailTextEle.getText()).toContain(origValue + textToAdd); + return backButtonEle.click(); + }); + } + +}); diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css new file mode 100644 index 0000000000..246b8c875b --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css @@ -0,0 +1,28 @@ +nav a { + padding: 5px 10px; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #eee; + border-radius: 4px; +} +nav a:visited, a:link { + color: #607D8B; +} +nav a:hover { + color: #039be5; + background-color: #CFD8DC; +} +nav a.router-link-active { + color: #039be5; +} +h1 { + font-size: 1.2em; + color: #999; + margin-bottom: 0; +} +h2 { + font-size: 2em; + margin-top: 0; + padding-top: 0; +} \ No newline at end of file diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts new file mode 100644 index 0000000000..3f5ea98de8 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; + +import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes/index'; +import { DashboardComponent } from './dashboard.component'; + +@Component({ + selector: 'my-app', + template: ` +

{{title}}

+ + + `, + styleUrls: ['app/app.component.css'], + directives: [ROUTER_DIRECTIVES], + providers: [HeroService] +}) +@RouteConfig([ + // {path: '/', redirectTo: ['Dashboard'] }, + {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true}, + {path: '/heroes', name: 'Heroes', component: HeroesComponent}, + {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent} +]) +export class AppComponent { + title = 'Tour of Heroes - Barrels'; +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css new file mode 100644 index 0000000000..d000c0c77e --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css @@ -0,0 +1,60 @@ +[class*='col-'] { + float: left; +} +*, *:after, *:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +h3 { + text-align: center; margin-bottom: 0; +} +[class*='col-'] { + padding-right: 20px; + padding-bottom: 20px; +} +[class*='col-']:last-of-type { + padding-right: 0; +} +.grid { + margin: 0; +} +.col-1-4 { + width: 25%; +} +.module { + padding: 20px; + text-align: center; + color: #eee; + max-height: 120px; + min-width: 120px; + background-color: #607D8B; + border-radius: 2px; +} +h4 { + position: relative; +} +.module:hover { + background-color: #EEE; + cursor: pointer; + color: #607d8b; +} +.grid-pad { + padding: 10px 0; +} +.grid-pad > [class*='col-']:last-of-type { + padding-right: 20px; +} +@media (max-width: 600px) { + .module { + font-size: 10px; + max-height: 75px; } +} +@media (max-width: 1024px) { + .grid { + margin: 0; + } + .module { + min-width: 60px; + } +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html new file mode 100644 index 0000000000..dfec651c4a --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html @@ -0,0 +1,8 @@ +

Top Heroes

+
+
+
+

{{hero.name}}

+
+
+
diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts new file mode 100644 index 0000000000..012cf812bc --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router-deprecated'; +import { Hero, HeroService } from './heroes/index'; + +@Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'] +}) +export class DashboardComponent implements OnInit { + heroes: Hero[] = []; + + constructor(private heroService: HeroService, private _router: Router) { } + + ngOnInit() { + this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5)); + } + + gotoDetail(hero: Hero) { + let link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); + } +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css new file mode 100644 index 0000000000..b5ab6e6e0b --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css @@ -0,0 +1,29 @@ +label { + display: inline-block; + width: 3em; + margin: .5em 0; + color: #607D8B; + font-weight: bold; +} +input { + height: 2em; + font-size: 1em; + padding-left: .4em; +} +button { + margin-top: 20px; + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} +button:disabled { + background-color: #eee; + color: #ccc; + cursor: auto; +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html new file mode 100644 index 0000000000..af9039dc9f --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html @@ -0,0 +1,10 @@ +
+

{{hero.name}} details!

+
+ {{hero.id}}
+
+ + +
+ +
\ No newline at end of file diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts new file mode 100644 index 0000000000..8d6fea52b1 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; +import { RouteParams } from '@angular/router-deprecated'; + +import { Hero, HeroService } from './index'; + +@Component({ + selector: 'my-hero-detail', + templateUrl: 'app/heroes/hero-detail.component.html', + styleUrls: ['app/heroes/hero-detail.component.css'] +}) +export class HeroDetailComponent implements OnInit { + hero: Hero; + + constructor(private heroService: HeroService, + private routeParams: RouteParams) { + } + + ngOnInit() { + let id = +this.routeParams.get('id'); + this.heroService.getHero(id).then(hero => this.hero = hero); + } + + goBack() { + window.history.back(); + } +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts new file mode 100644 index 0000000000..c2163e1b28 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; + +import { HEROES } from './../mock-heroes'; + +@Injectable() +export class HeroService { + getHeroes() { + return Promise.resolve(HEROES); + } + + getHero(id: number) { + return Promise.resolve(HEROES).then( + heroes => heroes.filter(hero => hero.id === id)[0] + ); + } +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts new file mode 100644 index 0000000000..e94ec6124a --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts @@ -0,0 +1,4 @@ +export class Hero { + id: number; + name: string; +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css new file mode 100644 index 0000000000..35e45af98d --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css @@ -0,0 +1,59 @@ +.selected { + background-color: #CFD8DC !important; + color: white; +} +.heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; +} +.heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; +} +.heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; +} +.heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; +} +.heroes .text { + position: relative; + top: -3px; +} +.heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; +} +button { + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html new file mode 100644 index 0000000000..6a973bb007 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html @@ -0,0 +1,14 @@ +
+

My Heroes

+ +
+

{{selectedHero.name | uppercase}} is my hero

+ +
+
diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts new file mode 100644 index 0000000000..1c4e24ddbe --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router-deprecated'; +import { HeroService, HeroDetailComponent, Hero } from './index'; + +@Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes/heroes.component.html', + styleUrls: ['app/heroes/heroes.component.css'], + directives: [HeroDetailComponent] +}) +export class HeroesComponent implements OnInit { + heroes: Hero[]; + selectedHero: Hero; + + constructor(private heroService: HeroService, private router: Router) { } + + getHeroes() { + this.heroService.getHeroes().then(heroes => this.heroes = heroes); + } + + gotoDetail() { + this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + } + + ngOnInit() { + this.getHeroes(); + } + + onSelect(hero: Hero) { this.selectedHero = hero; } +} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts new file mode 100644 index 0000000000..85f988a43c --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts @@ -0,0 +1,4 @@ +export * from './hero'; +export * from './hero-detail.component'; +export * from './hero.service'; +export * from './heroes.component'; diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/main.ts b/public/docs/_examples/cb-barrels.huh/ts/app/main.ts new file mode 100644 index 0000000000..c261ef5625 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/main.ts @@ -0,0 +1,10 @@ +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; + +import { HeroService } from './heroes/index'; +import { AppComponent } from './app.component'; + +bootstrap(AppComponent, [ + ROUTER_PROVIDERS, + HeroService +]); diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts new file mode 100644 index 0000000000..904368d532 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts @@ -0,0 +1,14 @@ +import { Hero } from './heroes/index'; + +export var HEROES: Hero[] = [ + {"id": 11, "name": "Mr. Nice"}, + {"id": 12, "name": "Narco"}, + {"id": 13, "name": "Bombasto"}, + {"id": 14, "name": "Celeritas"}, + {"id": 15, "name": "Magneta"}, + {"id": 16, "name": "RubberMan"}, + {"id": 17, "name": "Dynama"}, + {"id": 18, "name": "Dr IQ"}, + {"id": 19, "name": "Magma"}, + {"id": 20, "name": "Tornado"} +]; diff --git a/public/docs/_examples/cb-barrels.huh/ts/example-config.json b/public/docs/_examples/cb-barrels.huh/ts/example-config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/docs/_examples/cb-barrels.huh/ts/index.html b/public/docs/_examples/cb-barrels.huh/ts/index.html new file mode 100644 index 0000000000..ede4eb68e5 --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/index.html @@ -0,0 +1,26 @@ + + + + + Angular 2 Tour of Heroes + + + + + + + + + + + + + + + + + Loading... + + diff --git a/public/docs/_examples/cb-barrels.huh/ts/plnkr.json b/public/docs/_examples/cb-barrels.huh/ts/plnkr.json new file mode 100644 index 0000000000..fc4ea3e22c --- /dev/null +++ b/public/docs/_examples/cb-barrels.huh/ts/plnkr.json @@ -0,0 +1,8 @@ +{ + "description": "Tour of Heroes", + "files":[ + "!**/*.d.ts", + "!**/*.js" + ], + "tags": ["tutorial", "tour", "heroes"] +} diff --git a/public/docs/_examples/cb-barrels/e2e-spec.js b/public/docs/_examples/cb-barrels/e2e-spec.js new file mode 100644 index 0000000000..a109efb5a8 --- /dev/null +++ b/public/docs/_examples/cb-barrels/e2e-spec.js @@ -0,0 +1,110 @@ +describe('Tutorial', function () { + + beforeAll(function () { + browser.get(''); + }); + + function getPageStruct() { + hrefEles = element.all(by.css('my-app a')); + + return { + hrefs: hrefEles, + myDashboardHref: hrefEles.get(0), + myDashboardParent: element(by.css('my-app my-dashboard')), + topHeroes: element.all(by.css('my-app my-dashboard .module.hero')), + + myHeroesHref: hrefEles.get(1), + myHeroesParent: element(by.css('my-app my-heroes')), + allHeroes: element.all(by.css('my-app my-heroes li')), + + heroDetail: element(by.css('my-app my-hero-detail')) + } + } + + it('should be able to see the start screen', function () { + var page = getPageStruct(); + expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); + expect(page.myDashboardHref.getText()).toEqual("Dashboard"); + expect(page.myHeroesHref.getText()).toEqual("Heroes"); + }); + + it('should be able to see dashboard choices', function () { + var page = getPageStruct(); + expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices"); + }); + + it('should be able to toggle the views', function () { + var page = getPageStruct(); + + expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); + expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown"); + return page.myDashboardHref.click(); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); + }); + + }); + + it('should be able to edit details from "Dashboard" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); + var heroEle = page.topHeroes.get(3); + var heroDescrEle = heroEle.element(by.css('h4')); + var heroDescr; + return heroDescrEle.getText().then(function(text) { + heroDescr = text; + return heroEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-foo'); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); + expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); + }); + }); + + it('should be able to edit details from "Heroes" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); + var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); + var heroEle, heroDescr; + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); + heroEle = page.allHeroes.get(2); + return heroEle.getText(); + }).then(function(text) { + // remove leading 'id' from the element + heroDescr = text.substr(text.indexOf(' ')+1); + return heroEle.click(); + }).then(function() { + expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); + return viewDetailsButtonEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-bar'); + }).then(function() { + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); + expect(heroEle.getText()).toContain(heroDescr + '-bar'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); + }); + }); + + function editDetails(page, origValue, textToAdd) { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); + expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); + var inputEle = page.heroDetail.element(by.css('input')); + expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); + var backButtonEle = page.heroDetail.element(by.css('button')); + expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); + var detailTextEle = page.heroDetail.element(by.css('div h2')); + expect(detailTextEle.getText()).toContain(origValue); + return sendKeys(inputEle, textToAdd).then(function () { + expect(detailTextEle.getText()).toContain(origValue + textToAdd); + return backButtonEle.click(); + }); + } + +}); diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.css b/public/docs/_examples/cb-barrels/ts/app/app.component.css new file mode 100644 index 0000000000..246b8c875b --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.css @@ -0,0 +1,28 @@ +nav a { + padding: 5px 10px; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #eee; + border-radius: 4px; +} +nav a:visited, a:link { + color: #607D8B; +} +nav a:hover { + color: #039be5; + background-color: #CFD8DC; +} +nav a.router-link-active { + color: #039be5; +} +h1 { + font-size: 1.2em; + color: #999; + margin-bottom: 0; +} +h2 { + font-size: 2em; + margin-top: 0; + padding-top: 0; +} \ No newline at end of file diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.ts b/public/docs/_examples/cb-barrels/ts/app/app.component.ts new file mode 100644 index 0000000000..a53af1ba1e --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; + +import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes'; +import { DashboardComponent } from './dashboard.component'; + +@Component({ + selector: 'my-app', + template: ` +

{{title}}

+ + + `, + styleUrls: ['app/app.component.css'], + directives: [ROUTER_DIRECTIVES], + providers: [HeroService] +}) +@RouteConfig([ + // {path: '/', redirectTo: ['Dashboard'] }, + {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true}, + {path: '/heroes', name: 'Heroes', component: HeroesComponent}, + {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent} +]) +export class AppComponent { + title = 'Tour of Heroes - Barrels'; +} diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.css b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.css new file mode 100644 index 0000000000..d000c0c77e --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.css @@ -0,0 +1,60 @@ +[class*='col-'] { + float: left; +} +*, *:after, *:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +h3 { + text-align: center; margin-bottom: 0; +} +[class*='col-'] { + padding-right: 20px; + padding-bottom: 20px; +} +[class*='col-']:last-of-type { + padding-right: 0; +} +.grid { + margin: 0; +} +.col-1-4 { + width: 25%; +} +.module { + padding: 20px; + text-align: center; + color: #eee; + max-height: 120px; + min-width: 120px; + background-color: #607D8B; + border-radius: 2px; +} +h4 { + position: relative; +} +.module:hover { + background-color: #EEE; + cursor: pointer; + color: #607d8b; +} +.grid-pad { + padding: 10px 0; +} +.grid-pad > [class*='col-']:last-of-type { + padding-right: 20px; +} +@media (max-width: 600px) { + .module { + font-size: 10px; + max-height: 75px; } +} +@media (max-width: 1024px) { + .grid { + margin: 0; + } + .module { + min-width: 60px; + } +} diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.html b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.html new file mode 100644 index 0000000000..dfec651c4a --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.html @@ -0,0 +1,8 @@ +

Top Heroes

+
+
+
+

{{hero.name}}

+
+
+
diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts new file mode 100644 index 0000000000..86668141e9 --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router-deprecated'; +import { Hero, HeroService } from './heroes'; + +@Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'] +}) +export class DashboardComponent implements OnInit { + heroes: Hero[] = []; + + constructor(private heroService: HeroService, private _router: Router) { } + + ngOnInit() { + this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5)); + } + + gotoDetail(hero: Hero) { + let link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); + } +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css new file mode 100644 index 0000000000..b5ab6e6e0b --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css @@ -0,0 +1,29 @@ +label { + display: inline-block; + width: 3em; + margin: .5em 0; + color: #607D8B; + font-weight: bold; +} +input { + height: 2em; + font-size: 1em; + padding-left: .4em; +} +button { + margin-top: 20px; + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} +button:disabled { + background-color: #eee; + color: #ccc; + cursor: auto; +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html new file mode 100644 index 0000000000..af9039dc9f --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html @@ -0,0 +1,10 @@ +
+

{{hero.name}} details!

+
+ {{hero.id}}
+
+ + +
+ +
\ No newline at end of file diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts new file mode 100644 index 0000000000..189c3a79dc --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts @@ -0,0 +1,27 @@ +import { Component, OnInit } 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/heroes/hero-detail.component.html', + styleUrls: ['app/heroes/hero-detail.component.css'] +}) +export class HeroDetailComponent implements OnInit { + hero: Hero; + + constructor(private heroService: HeroService, + private routeParams: RouteParams) { + } + + ngOnInit() { + let id = +this.routeParams.get('id'); + this.heroService.getHero(id).then(hero => this.hero = hero); + } + + goBack() { + window.history.back(); + } +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts new file mode 100644 index 0000000000..24e17a3809 --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; + +import { HEROES } from './../mock-heroes'; + +@Injectable() +export class HeroService { + getHeroes() { + return Promise.resolve(HEROES); + } + + getHero(id: number) { + return Promise.resolve(HEROES).then( + heroes => heroes.filter(hero => hero.id === id)[0] + ); + } +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts new file mode 100644 index 0000000000..e94ec6124a --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts @@ -0,0 +1,4 @@ +export class Hero { + id: number; + name: string; +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.css b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.css new file mode 100644 index 0000000000..35e45af98d --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.css @@ -0,0 +1,59 @@ +.selected { + background-color: #CFD8DC !important; + color: white; +} +.heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; +} +.heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; +} +.heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; +} +.heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; +} +.heroes .text { + position: relative; + top: -3px; +} +.heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; +} +button { + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.html b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.html new file mode 100644 index 0000000000..6a973bb007 --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.html @@ -0,0 +1,14 @@ +
+

My Heroes

+ +
+

{{selectedHero.name | uppercase}} is my hero

+ +
+
diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts new file mode 100644 index 0000000000..6d41b3923f --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router-deprecated'; +import { HeroService, HeroDetailComponent, Hero } from '../heroes'; + +@Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes/heroes.component.html', + styleUrls: ['app/heroes/heroes.component.css'], + directives: [HeroDetailComponent] +}) +export class HeroesComponent implements OnInit { + heroes: Hero[]; + selectedHero: Hero; + + constructor(private heroService: HeroService, private router: Router) { } + + getHeroes() { + this.heroService.getHeroes().then(heroes => this.heroes = heroes); + } + + gotoDetail() { + this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + } + + ngOnInit() { + this.getHeroes(); + } + + onSelect(hero: Hero) { this.selectedHero = hero; } +} diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts new file mode 100644 index 0000000000..85f988a43c --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts @@ -0,0 +1,4 @@ +export * from './hero'; +export * from './hero-detail.component'; +export * from './hero.service'; +export * from './heroes.component'; diff --git a/public/docs/_examples/cb-barrels/ts/app/main.ts b/public/docs/_examples/cb-barrels/ts/app/main.ts new file mode 100644 index 0000000000..45c00aa030 --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/main.ts @@ -0,0 +1,10 @@ +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; + +import { HeroService } from './heroes'; +import { AppComponent } from './app.component'; + +bootstrap(AppComponent, [ + ROUTER_PROVIDERS, + HeroService +]); diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts new file mode 100644 index 0000000000..53271aa12e --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts @@ -0,0 +1,14 @@ +import { Hero } from './heroes'; + +export var HEROES: Hero[] = [ + {"id": 11, "name": "Mr. Nice"}, + {"id": 12, "name": "Narco"}, + {"id": 13, "name": "Bombasto"}, + {"id": 14, "name": "Celeritas"}, + {"id": 15, "name": "Magneta"}, + {"id": 16, "name": "RubberMan"}, + {"id": 17, "name": "Dynama"}, + {"id": 18, "name": "Dr IQ"}, + {"id": 19, "name": "Magma"}, + {"id": 20, "name": "Tornado"} +]; diff --git a/public/docs/_examples/cb-barrels/ts/example-config.json b/public/docs/_examples/cb-barrels/ts/example-config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/docs/_examples/cb-barrels/ts/index.html b/public/docs/_examples/cb-barrels/ts/index.html new file mode 100644 index 0000000000..ede4eb68e5 --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/index.html @@ -0,0 +1,26 @@ + + + + + Angular 2 Tour of Heroes + + + + + + + + + + + + + + + + + Loading... + + diff --git a/public/docs/_examples/cb-barrels/ts/plnkr.json b/public/docs/_examples/cb-barrels/ts/plnkr.json new file mode 100644 index 0000000000..fc4ea3e22c --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/plnkr.json @@ -0,0 +1,8 @@ +{ + "description": "Tour of Heroes", + "files":[ + "!**/*.d.ts", + "!**/*.js" + ], + "tags": ["tutorial", "tour", "heroes"] +} diff --git a/public/docs/ts/latest/cookbook/_data.json b/public/docs/ts/latest/cookbook/_data.json index 211e12bfd4..0f11368d41 100644 --- a/public/docs/ts/latest/cookbook/_data.json +++ b/public/docs/ts/latest/cookbook/_data.json @@ -11,6 +11,11 @@ "intro": "Learn how Angular 1 concepts and techniques map to Angular 2" }, + "barrels": { + "title": "Creating Barrels", + "intro": "Create and use barrels to simplify module imports" + }, + "component-communication": { "title": "Component Interaction", "intro": "Share information between different directives and components" diff --git a/public/docs/ts/latest/cookbook/barrels.jade b/public/docs/ts/latest/cookbook/barrels.jade new file mode 100644 index 0000000000..6b8c2e3d3c --- /dev/null +++ b/public/docs/ts/latest/cookbook/barrels.jade @@ -0,0 +1,68 @@ +include ../_util-fns + + +:marked + This cookbook contains recipes for creating barrels to simplify file imports. In Angular 2 apps, we frequently find + ouselves importing multiple files together (for example, in the tutorial app, the hero component and the hero service + are both frequently imported together into other components). We can create a single import that contains them both. + This is called a barrel. + + +:marked + ## Table of contents + + [Creating a barrel](#creating-a-barrel) + + [Importing a barrel](#importing-a-barrel) + +:marked + **See the [live example](/resources/live-examples/cb-barrels/ts/plnkr.html)**. + +.l-main-section + +:marked + ## Creating a barrel + + 'Hero', `HeroDetailComponent`, `HeroService`, and `HeroesComponent` are all frequently used together. Each of them + are moved into a `heroes` directory with their supporting files: + +
+    /heroes
+      hero-detail.component.css
+      hero-detail.component.html
+      hero-detail.component.ts
+      hero-service.ts
+      hero.ts
+      heroes.component.css
+      heroes.component.html
+      heroes.component.ts
+  
+ + An `index.ts` file is created in the `/heroes` directory. And each of the files is imported and re-exported: ++makeExample('cb-barrels/ts/app/heroes/index.ts') + +:marked + Each of the files are now available as a single import. + + +:marked + ## Importing a barrel + The app component imports `HeroesComponent`, `HeroDetailComponent`, and `HeroService` with a + single import: ++makeExample('cb-barrels/ts/app/app.component.ts') + +:marked + The dashboard component imports `Hero` and `HeroService` with a single import: ++makeExample('cb-barrels/ts/app/dashboard.component.ts') + +:marked + The `main.ts` bootstrap file imports `HeroService` ++makeExample('cb-barrels/ts/app/main.ts') + +:marked + The `mock-heroes.ts` file imports `Hero`: ++makeExample('cb-barrels/ts/app/mock-heroes.ts') + +:marked + The files inside the `/heroes` barrel are updated to add `../` to module imports outside the barrel. They are also + updated to use the barrel for any references within the barrel using `../heroes`. From cdea51ce837ff81177a71e1e2f6bb845f8e58c79 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Mon, 16 May 2016 20:22:37 -0600 Subject: [PATCH 02/41] Remove unused files --- .../docs/_examples/cb-barrels.huh/e2e-spec.js | 110 ------------------ .../cb-barrels.huh/ts/app/app.component.css | 28 ----- .../cb-barrels.huh/ts/app/app.component.ts | 29 ----- .../ts/app/dashboard.component.css | 60 ---------- .../ts/app/dashboard.component.html | 8 -- .../ts/app/dashboard.component.ts | 23 ---- .../ts/app/heroes/hero-detail.component.css | 29 ----- .../ts/app/heroes/hero-detail.component.html | 10 -- .../ts/app/heroes/hero-detail.component.ts | 26 ----- .../ts/app/heroes/hero.service.ts | 16 --- .../cb-barrels.huh/ts/app/heroes/hero.ts | 4 - .../ts/app/heroes/heroes.component.css | 59 ---------- .../ts/app/heroes/heroes.component.html | 14 --- .../ts/app/heroes/heroes.component.ts | 30 ----- .../cb-barrels.huh/ts/app/heroes/index.ts | 4 - .../_examples/cb-barrels.huh/ts/app/main.ts | 10 -- .../cb-barrels.huh/ts/app/mock-heroes.ts | 14 --- .../cb-barrels.huh/ts/example-config.json | 0 .../_examples/cb-barrels.huh/ts/index.html | 26 ----- .../_examples/cb-barrels.huh/ts/plnkr.json | 8 -- 20 files changed, 508 deletions(-) delete mode 100644 public/docs/_examples/cb-barrels.huh/e2e-spec.js delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/app.component.css delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/main.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/example-config.json delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/index.html delete mode 100644 public/docs/_examples/cb-barrels.huh/ts/plnkr.json diff --git a/public/docs/_examples/cb-barrels.huh/e2e-spec.js b/public/docs/_examples/cb-barrels.huh/e2e-spec.js deleted file mode 100644 index a109efb5a8..0000000000 --- a/public/docs/_examples/cb-barrels.huh/e2e-spec.js +++ /dev/null @@ -1,110 +0,0 @@ -describe('Tutorial', function () { - - beforeAll(function () { - browser.get(''); - }); - - function getPageStruct() { - hrefEles = element.all(by.css('my-app a')); - - return { - hrefs: hrefEles, - myDashboardHref: hrefEles.get(0), - myDashboardParent: element(by.css('my-app my-dashboard')), - topHeroes: element.all(by.css('my-app my-dashboard .module.hero')), - - myHeroesHref: hrefEles.get(1), - myHeroesParent: element(by.css('my-app my-heroes')), - allHeroes: element.all(by.css('my-app my-heroes li')), - - heroDetail: element(by.css('my-app my-hero-detail')) - } - } - - it('should be able to see the start screen', function () { - var page = getPageStruct(); - expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); - expect(page.myDashboardHref.getText()).toEqual("Dashboard"); - expect(page.myHeroesHref.getText()).toEqual("Heroes"); - }); - - it('should be able to see dashboard choices', function () { - var page = getPageStruct(); - expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices"); - }); - - it('should be able to toggle the views', function () { - var page = getPageStruct(); - - expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); - expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown"); - return page.myDashboardHref.click(); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); - }); - - }); - - it('should be able to edit details from "Dashboard" view', function () { - var page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); - var heroEle = page.topHeroes.get(3); - var heroDescrEle = heroEle.element(by.css('h4')); - var heroDescr; - return heroDescrEle.getText().then(function(text) { - heroDescr = text; - return heroEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-foo'); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); - expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); - }); - }); - - it('should be able to edit details from "Heroes" view', function () { - var page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); - var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); - var heroEle, heroDescr; - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); - heroEle = page.allHeroes.get(2); - return heroEle.getText(); - }).then(function(text) { - // remove leading 'id' from the element - heroDescr = text.substr(text.indexOf(' ')+1); - return heroEle.click(); - }).then(function() { - expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); - return viewDetailsButtonEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-bar'); - }).then(function() { - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); - expect(heroEle.getText()).toContain(heroDescr + '-bar'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); - }); - }); - - function editDetails(page, origValue, textToAdd) { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); - expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); - var inputEle = page.heroDetail.element(by.css('input')); - expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); - var backButtonEle = page.heroDetail.element(by.css('button')); - expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); - var detailTextEle = page.heroDetail.element(by.css('div h2')); - expect(detailTextEle.getText()).toContain(origValue); - return sendKeys(inputEle, textToAdd).then(function () { - expect(detailTextEle.getText()).toContain(origValue + textToAdd); - return backButtonEle.click(); - }); - } - -}); diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css deleted file mode 100644 index 246b8c875b..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.css +++ /dev/null @@ -1,28 +0,0 @@ -nav a { - padding: 5px 10px; - text-decoration: none; - margin-top: 10px; - display: inline-block; - background-color: #eee; - border-radius: 4px; -} -nav a:visited, a:link { - color: #607D8B; -} -nav a:hover { - color: #039be5; - background-color: #CFD8DC; -} -nav a.router-link-active { - color: #039be5; -} -h1 { - font-size: 1.2em; - color: #999; - margin-bottom: 0; -} -h2 { - font-size: 2em; - margin-top: 0; - padding-top: 0; -} \ No newline at end of file diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts deleted file mode 100644 index 3f5ea98de8..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/app.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component } from '@angular/core'; -import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; - -import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes/index'; -import { DashboardComponent } from './dashboard.component'; - -@Component({ - selector: 'my-app', - template: ` -

{{title}}

- - - `, - styleUrls: ['app/app.component.css'], - directives: [ROUTER_DIRECTIVES], - providers: [HeroService] -}) -@RouteConfig([ - // {path: '/', redirectTo: ['Dashboard'] }, - {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true}, - {path: '/heroes', name: 'Heroes', component: HeroesComponent}, - {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent} -]) -export class AppComponent { - title = 'Tour of Heroes - Barrels'; -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css deleted file mode 100644 index d000c0c77e..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.css +++ /dev/null @@ -1,60 +0,0 @@ -[class*='col-'] { - float: left; -} -*, *:after, *:before { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -h3 { - text-align: center; margin-bottom: 0; -} -[class*='col-'] { - padding-right: 20px; - padding-bottom: 20px; -} -[class*='col-']:last-of-type { - padding-right: 0; -} -.grid { - margin: 0; -} -.col-1-4 { - width: 25%; -} -.module { - padding: 20px; - text-align: center; - color: #eee; - max-height: 120px; - min-width: 120px; - background-color: #607D8B; - border-radius: 2px; -} -h4 { - position: relative; -} -.module:hover { - background-color: #EEE; - cursor: pointer; - color: #607d8b; -} -.grid-pad { - padding: 10px 0; -} -.grid-pad > [class*='col-']:last-of-type { - padding-right: 20px; -} -@media (max-width: 600px) { - .module { - font-size: 10px; - max-height: 75px; } -} -@media (max-width: 1024px) { - .grid { - margin: 0; - } - .module { - min-width: 60px; - } -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html deleted file mode 100644 index dfec651c4a..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.html +++ /dev/null @@ -1,8 +0,0 @@ -

Top Heroes

-
-
-
-

{{hero.name}}

-
-
-
diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts deleted file mode 100644 index 012cf812bc..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/dashboard.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router-deprecated'; -import { Hero, HeroService } from './heroes/index'; - -@Component({ - selector: 'my-dashboard', - templateUrl: 'app/dashboard.component.html', - styleUrls: ['app/dashboard.component.css'] -}) -export class DashboardComponent implements OnInit { - heroes: Hero[] = []; - - constructor(private heroService: HeroService, private _router: Router) { } - - ngOnInit() { - this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5)); - } - - gotoDetail(hero: Hero) { - let link = ['HeroDetail', { id: hero.id }]; - this._router.navigate(link); - } -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css deleted file mode 100644 index b5ab6e6e0b..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.css +++ /dev/null @@ -1,29 +0,0 @@ -label { - display: inline-block; - width: 3em; - margin: .5em 0; - color: #607D8B; - font-weight: bold; -} -input { - height: 2em; - font-size: 1em; - padding-left: .4em; -} -button { - margin-top: 20px; - font-family: Arial; - background-color: #eee; - border: none; - padding: 5px 10px; - border-radius: 4px; - cursor: pointer; cursor: hand; -} -button:hover { - background-color: #cfd8dc; -} -button:disabled { - background-color: #eee; - color: #ccc; - cursor: auto; -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html deleted file mode 100644 index af9039dc9f..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
-

{{hero.name}} details!

-
- {{hero.id}}
-
- - -
- -
\ No newline at end of file diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts deleted file mode 100644 index 8d6fea52b1..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero-detail.component.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { RouteParams } from '@angular/router-deprecated'; - -import { Hero, HeroService } from './index'; - -@Component({ - selector: 'my-hero-detail', - templateUrl: 'app/heroes/hero-detail.component.html', - styleUrls: ['app/heroes/hero-detail.component.css'] -}) -export class HeroDetailComponent implements OnInit { - hero: Hero; - - constructor(private heroService: HeroService, - private routeParams: RouteParams) { - } - - ngOnInit() { - let id = +this.routeParams.get('id'); - this.heroService.getHero(id).then(hero => this.hero = hero); - } - - goBack() { - window.history.back(); - } -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts deleted file mode 100644 index c2163e1b28..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Injectable } from '@angular/core'; - -import { HEROES } from './../mock-heroes'; - -@Injectable() -export class HeroService { - getHeroes() { - return Promise.resolve(HEROES); - } - - getHero(id: number) { - return Promise.resolve(HEROES).then( - heroes => heroes.filter(hero => hero.id === id)[0] - ); - } -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts deleted file mode 100644 index e94ec6124a..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/hero.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class Hero { - id: number; - name: string; -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css deleted file mode 100644 index 35e45af98d..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.css +++ /dev/null @@ -1,59 +0,0 @@ -.selected { - background-color: #CFD8DC !important; - color: white; -} -.heroes { - margin: 0 0 2em 0; - list-style-type: none; - padding: 0; - width: 15em; -} -.heroes li { - cursor: pointer; - position: relative; - left: 0; - background-color: #EEE; - margin: .5em; - padding: .3em 0; - height: 1.6em; - border-radius: 4px; -} -.heroes li:hover { - color: #607D8B; - background-color: #DDD; - left: .1em; -} -.heroes li.selected:hover { - background-color: #BBD8DC !important; - color: white; -} -.heroes .text { - position: relative; - top: -3px; -} -.heroes .badge { - display: inline-block; - font-size: small; - color: white; - padding: 0.8em 0.7em 0 0.7em; - background-color: #607D8B; - line-height: 1em; - position: relative; - left: -1px; - top: -4px; - height: 1.8em; - margin-right: .8em; - border-radius: 4px 0 0 4px; -} -button { - font-family: Arial; - background-color: #eee; - border: none; - padding: 5px 10px; - border-radius: 4px; - cursor: pointer; - cursor: hand; -} -button:hover { - background-color: #cfd8dc; -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html deleted file mode 100644 index 6a973bb007..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
-

My Heroes

-
    -
  • - {{hero.id}} {{hero.name}} -
  • -
-
-

{{selectedHero.name | uppercase}} is my hero

- -
-
diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts deleted file mode 100644 index 1c4e24ddbe..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/heroes.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router-deprecated'; -import { HeroService, HeroDetailComponent, Hero } from './index'; - -@Component({ - selector: 'my-heroes', - templateUrl: 'app/heroes/heroes.component.html', - styleUrls: ['app/heroes/heroes.component.css'], - directives: [HeroDetailComponent] -}) -export class HeroesComponent implements OnInit { - heroes: Hero[]; - selectedHero: Hero; - - constructor(private heroService: HeroService, private router: Router) { } - - getHeroes() { - this.heroService.getHeroes().then(heroes => this.heroes = heroes); - } - - gotoDetail() { - this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]); - } - - ngOnInit() { - this.getHeroes(); - } - - onSelect(hero: Hero) { this.selectedHero = hero; } -} diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts b/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts deleted file mode 100644 index 85f988a43c..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/heroes/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './hero'; -export * from './hero-detail.component'; -export * from './hero.service'; -export * from './heroes.component'; diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/main.ts b/public/docs/_examples/cb-barrels.huh/ts/app/main.ts deleted file mode 100644 index c261ef5625..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/main.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; - -import { HeroService } from './heroes/index'; -import { AppComponent } from './app.component'; - -bootstrap(AppComponent, [ - ROUTER_PROVIDERS, - HeroService -]); diff --git a/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts deleted file mode 100644 index 904368d532..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/app/mock-heroes.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Hero } from './heroes/index'; - -export var HEROES: Hero[] = [ - {"id": 11, "name": "Mr. Nice"}, - {"id": 12, "name": "Narco"}, - {"id": 13, "name": "Bombasto"}, - {"id": 14, "name": "Celeritas"}, - {"id": 15, "name": "Magneta"}, - {"id": 16, "name": "RubberMan"}, - {"id": 17, "name": "Dynama"}, - {"id": 18, "name": "Dr IQ"}, - {"id": 19, "name": "Magma"}, - {"id": 20, "name": "Tornado"} -]; diff --git a/public/docs/_examples/cb-barrels.huh/ts/example-config.json b/public/docs/_examples/cb-barrels.huh/ts/example-config.json deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/cb-barrels.huh/ts/index.html b/public/docs/_examples/cb-barrels.huh/ts/index.html deleted file mode 100644 index ede4eb68e5..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Angular 2 Tour of Heroes - - - - - - - - - - - - - - - - - Loading... - - diff --git a/public/docs/_examples/cb-barrels.huh/ts/plnkr.json b/public/docs/_examples/cb-barrels.huh/ts/plnkr.json deleted file mode 100644 index fc4ea3e22c..0000000000 --- a/public/docs/_examples/cb-barrels.huh/ts/plnkr.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": "Tour of Heroes", - "files":[ - "!**/*.d.ts", - "!**/*.js" - ], - "tags": ["tutorial", "tour", "heroes"] -} From 035d80d2988298bb674897415cb8b0ba796700cb Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Mon, 16 May 2016 21:59:16 -0600 Subject: [PATCH 03/41] docs(cb-barrels): Clean up copy/paste --- public/docs/_examples/cb-barrels/ts/index.html | 2 +- public/docs/_examples/cb-barrels/ts/plnkr.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/docs/_examples/cb-barrels/ts/index.html b/public/docs/_examples/cb-barrels/ts/index.html index ede4eb68e5..99dd3b6e07 100644 --- a/public/docs/_examples/cb-barrels/ts/index.html +++ b/public/docs/_examples/cb-barrels/ts/index.html @@ -2,7 +2,7 @@ - Angular 2 Tour of Heroes + Angular 2 Tour of Heroes - Barrels diff --git a/public/docs/_examples/cb-barrels/ts/plnkr.json b/public/docs/_examples/cb-barrels/ts/plnkr.json index fc4ea3e22c..5f0eca25e7 100644 --- a/public/docs/_examples/cb-barrels/ts/plnkr.json +++ b/public/docs/_examples/cb-barrels/ts/plnkr.json @@ -1,8 +1,8 @@ { - "description": "Tour of Heroes", + "description": "Cookbook: Barrels", "files":[ "!**/*.d.ts", "!**/*.js" ], - "tags": ["tutorial", "tour", "heroes"] + "tags": ["cookbook", "barrels"] } From 0a6b13811b6a1078ce6b4e4e55905bde55a3990a Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Mon, 16 May 2016 21:59:47 -0600 Subject: [PATCH 04/41] Add // #docregion --- public/docs/_examples/cb-barrels/ts/app/app.component.ts | 1 + public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts | 1 + public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts | 1 + public/docs/_examples/cb-barrels/ts/app/heroes/index.ts | 1 + public/docs/_examples/cb-barrels/ts/app/main.ts | 1 + public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts | 1 + 6 files changed, 6 insertions(+) diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.ts b/public/docs/_examples/cb-barrels/ts/app/app.component.ts index a53af1ba1e..c19935e032 100644 --- a/public/docs/_examples/cb-barrels/ts/app/app.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.ts @@ -1,3 +1,4 @@ +// #docregion import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts index 86668141e9..672136d6dc 100644 --- a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts @@ -1,3 +1,4 @@ +// #docregion import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; import { Hero, HeroService } from './heroes'; diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts index e94ec6124a..1117bdd832 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts @@ -2,3 +2,4 @@ export class Hero { id: number; name: string; } + diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts index 85f988a43c..8f98b1c560 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts @@ -1,3 +1,4 @@ +// #docregion export * from './hero'; export * from './hero-detail.component'; export * from './hero.service'; diff --git a/public/docs/_examples/cb-barrels/ts/app/main.ts b/public/docs/_examples/cb-barrels/ts/app/main.ts index 45c00aa030..255f0b511f 100644 --- a/public/docs/_examples/cb-barrels/ts/app/main.ts +++ b/public/docs/_examples/cb-barrels/ts/app/main.ts @@ -1,3 +1,4 @@ +// #docregion import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts index 53271aa12e..782ec9fda3 100644 --- a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts +++ b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts @@ -1,3 +1,4 @@ +// #docregion import { Hero } from './heroes'; export var HEROES: Hero[] = [ From 53f97bf50e85062c613064c075d2c7f9f773a3d0 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Mon, 16 May 2016 22:33:22 -0600 Subject: [PATCH 05/41] docs(cb-barrels): Add #docregions and finish recipe --- .../cb-barrels/ts/app/app.component.ts | 4 +-- .../cb-barrels/ts/app/dashboard.component.ts | 3 +- .../ts/app/heroes/hero-detail.component.ts | 6 ++-- .../cb-barrels/ts/app/heroes/hero.service.ts | 5 ++-- .../ts/app/heroes/heroes.component.ts | 2 ++ .../docs/_examples/cb-barrels/ts/app/main.ts | 4 +-- .../cb-barrels/ts/app/mock-heroes.ts | 6 ++-- public/docs/ts/latest/cookbook/barrels.jade | 29 ++++++++++++++----- 8 files changed, 39 insertions(+), 20 deletions(-) diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.ts b/public/docs/_examples/cb-barrels/ts/app/app.component.ts index c19935e032..926eafc1c9 100644 --- a/public/docs/_examples/cb-barrels/ts/app/app.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.ts @@ -1,11 +1,11 @@ -// #docregion +// #docregion imports import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; - import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes'; import { DashboardComponent } from './dashboard.component'; @Component({ +// #enddocregion selector: 'my-app', template: `

{{title}}

diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts index 672136d6dc..1239207374 100644 --- a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts @@ -1,9 +1,10 @@ -// #docregion +// #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; import { Hero, HeroService } from './heroes'; @Component({ +// #enddocregion selector: 'my-dashboard', templateUrl: 'app/dashboard.component.html', styleUrls: ['app/dashboard.component.css'] diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts index 189c3a79dc..31b2f94041 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts @@ -1,10 +1,10 @@ +// #docregion imports import { Component, OnInit } from '@angular/core'; import { RouteParams } from '@angular/router-deprecated'; - -import { Hero } from './hero'; -import { HeroService } from './hero.service'; +import { Hero, HeroService } from './hero.service'; @Component({ +// #enddocregion selector: 'my-hero-detail', templateUrl: 'app/heroes/hero-detail.component.html', styleUrls: ['app/heroes/hero-detail.component.css'] diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts index 24e17a3809..2f4ef35fc8 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts @@ -1,9 +1,10 @@ +// #docregion imports import { Injectable } from '@angular/core'; - -import { HEROES } from './../mock-heroes'; +import { HEROES } from '../mock-heroes'; @Injectable() export class HeroService { +// #enddocregion getHeroes() { return Promise.resolve(HEROES); } diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts index 6d41b3923f..e3d692e5d0 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts @@ -1,8 +1,10 @@ +// #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; import { HeroService, HeroDetailComponent, Hero } from '../heroes'; @Component({ +// #enddocregion selector: 'my-heroes', templateUrl: 'app/heroes/heroes.component.html', styleUrls: ['app/heroes/heroes.component.css'], diff --git a/public/docs/_examples/cb-barrels/ts/app/main.ts b/public/docs/_examples/cb-barrels/ts/app/main.ts index 255f0b511f..09288fb174 100644 --- a/public/docs/_examples/cb-barrels/ts/app/main.ts +++ b/public/docs/_examples/cb-barrels/ts/app/main.ts @@ -1,11 +1,11 @@ -// #docregion +// #docregion imports import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; - import { HeroService } from './heroes'; import { AppComponent } from './app.component'; bootstrap(AppComponent, [ +// #enddocregion ROUTER_PROVIDERS, HeroService ]); diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts index 782ec9fda3..cfcffa5ce3 100644 --- a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts +++ b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts @@ -1,8 +1,10 @@ -// #docregion +// #docregion imports import { Hero } from './heroes'; export var HEROES: Hero[] = [ - {"id": 11, "name": "Mr. Nice"}, +// #enddocregion + + {"id": 11, "name": "Mr. Nice"}, {"id": 12, "name": "Narco"}, {"id": 13, "name": "Bombasto"}, {"id": 14, "name": "Celeritas"}, diff --git a/public/docs/ts/latest/cookbook/barrels.jade b/public/docs/ts/latest/cookbook/barrels.jade index 6b8c2e3d3c..a21b0097e9 100644 --- a/public/docs/ts/latest/cookbook/barrels.jade +++ b/public/docs/ts/latest/cookbook/barrels.jade @@ -39,7 +39,7 @@ include ../_util-fns An `index.ts` file is created in the `/heroes` directory. And each of the files is imported and re-exported: -+makeExample('cb-barrels/ts/app/heroes/index.ts') ++makeExample('cb-barrels/ts/app/heroes/index.ts', '', 'app/heroes/index.ts') :marked Each of the files are now available as a single import. @@ -49,20 +49,33 @@ include ../_util-fns ## Importing a barrel The app component imports `HeroesComponent`, `HeroDetailComponent`, and `HeroService` with a single import: -+makeExample('cb-barrels/ts/app/app.component.ts') ++makeExample('cb-barrels/ts/app/app.component.ts', 'imports', 'app/app.component.ts') :marked The dashboard component imports `Hero` and `HeroService` with a single import: -+makeExample('cb-barrels/ts/app/dashboard.component.ts') ++makeExample('cb-barrels/ts/app/dashboard.component.ts', 'imports', 'app/dashboard.component.ts') :marked - The `main.ts` bootstrap file imports `HeroService` -+makeExample('cb-barrels/ts/app/main.ts') + The `main.ts` bootstrap file imports `HeroService`: ++makeExample('cb-barrels/ts/app/main.ts', 'imports', 'app/main.ts') :marked The `mock-heroes.ts` file imports `Hero`: -+makeExample('cb-barrels/ts/app/mock-heroes.ts') ++makeExample('cb-barrels/ts/app/mock-heroes.ts', 'imports', 'app/mock-heroes.ts') :marked - The files inside the `/heroes` barrel are updated to add `../` to module imports outside the barrel. They are also - updated to use the barrel for any references within the barrel using `../heroes`. + The files inside the `/heroes` barrel are updated to use the barrel for any references within the + barrel intself by using `../heroes`. Since they were moved into a new folder, they are also updated to add `../` + to module imports outside the barrel. + ++makeTabs( + `cb-barrels/ts/app/heroes/hero.service.ts, + cb-barrels/ts/app/heroes/hero-detail.component.ts, + cb-barrels/ts/app/heroes/heroes.component.ts`, + `imports, + imports, + imports`, + `app/heroes/hero.service.ts, + app/heroes/hero-detail.component.ts, + app/heroes/heroes.component.ts` +) From d8ab627a2272b42ef5d3ba0c677e42f93a7e39ac Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Tue, 17 May 2016 01:41:32 -0600 Subject: [PATCH 06/41] Update imports to use /index for now --- .../cb-barrels/ts/app/app.component.ts | 2 +- .../cb-barrels/ts/app/dashboard.component.ts | 2 +- .../ts/app/heroes/hero-detail.component.ts | 3 +- .../ts/app/heroes/heroes.component.ts | 4 +- .../docs/_examples/cb-barrels/ts/app/main.ts | 2 +- .../cb-barrels/ts/app/mock-heroes.ts | 2 +- public/docs/ts/latest/cookbook/barrels.jade | 41 ++++++++++--------- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.ts b/public/docs/_examples/cb-barrels/ts/app/app.component.ts index 926eafc1c9..b8ff9cc9a0 100644 --- a/public/docs/_examples/cb-barrels/ts/app/app.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.ts @@ -1,7 +1,7 @@ // #docregion imports import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; -import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes'; +import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes/index'; import { DashboardComponent } from './dashboard.component'; @Component({ diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts index 1239207374..3a6b327934 100644 --- a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts @@ -1,7 +1,7 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; -import { Hero, HeroService } from './heroes'; +import { Hero, HeroService } from './heroes/index'; @Component({ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts index 31b2f94041..e6db3ae4bd 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts @@ -1,7 +1,8 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { RouteParams } from '@angular/router-deprecated'; -import { Hero, HeroService } from './hero.service'; +import { HeroService } from './hero.service'; +import { Hero } from './hero'; @Component({ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts index e3d692e5d0..41db767098 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts @@ -1,7 +1,9 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; -import { HeroService, HeroDetailComponent, Hero } from '../heroes'; +import { HeroService } from './hero.service'; +import { HeroDetailComponent } from './hero-detail.component' +import { Hero } from './hero'; @Component({ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/app/main.ts b/public/docs/_examples/cb-barrels/ts/app/main.ts index 09288fb174..a1baa78d94 100644 --- a/public/docs/_examples/cb-barrels/ts/app/main.ts +++ b/public/docs/_examples/cb-barrels/ts/app/main.ts @@ -1,7 +1,7 @@ // #docregion imports import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; -import { HeroService } from './heroes'; +import { HeroService } from './heroes/index'; import { AppComponent } from './app.component'; bootstrap(AppComponent, [ diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts index cfcffa5ce3..544aa1d4a4 100644 --- a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts +++ b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts @@ -1,5 +1,5 @@ // #docregion imports -import { Hero } from './heroes'; +import { Hero } from './heroes/index'; export var HEROES: Hero[] = [ // #enddocregion diff --git a/public/docs/ts/latest/cookbook/barrels.jade b/public/docs/ts/latest/cookbook/barrels.jade index a21b0097e9..70b2312301 100644 --- a/public/docs/ts/latest/cookbook/barrels.jade +++ b/public/docs/ts/latest/cookbook/barrels.jade @@ -3,14 +3,14 @@ include ../_util-fns :marked This cookbook contains recipes for creating barrels to simplify file imports. In Angular 2 apps, we frequently find - ouselves importing multiple files together (for example, in the tutorial app, the hero component and the hero service - are both frequently imported together into other components). We can create a single import that contains them both. + ouselves importing multiple files together (for example, in the tutorial app, the hero component and the hero service + are both frequently imported together into other components). We can create a single export that contains them both. This is called a barrel. :marked ## Table of contents - + [Creating a barrel](#creating-a-barrel) [Importing a barrel](#importing-a-barrel) @@ -22,10 +22,10 @@ include ../_util-fns :marked ## Creating a barrel - - 'Hero', `HeroDetailComponent`, `HeroService`, and `HeroesComponent` are all frequently used together. Each of them + + `Hero`, `HeroDetailComponent`, `HeroService`, and `HeroesComponent` are all frequently used together. Each of them are moved into a `heroes` directory with their supporting files: - +
     /heroes
       hero-detail.component.css
@@ -37,13 +37,13 @@ include ../_util-fns
       heroes.component.html
       heroes.component.ts
   
- + An `index.ts` file is created in the `/heroes` directory. And each of the files is imported and re-exported: +makeExample('cb-barrels/ts/app/heroes/index.ts', '', 'app/heroes/index.ts') :marked - Each of the files are now available as a single import. - + Each of the files are now available as a single import. + :marked ## Importing a barrel @@ -63,19 +63,22 @@ include ../_util-fns The `mock-heroes.ts` file imports `Hero`: +makeExample('cb-barrels/ts/app/mock-heroes.ts', 'imports', 'app/mock-heroes.ts') -:marked - The files inside the `/heroes` barrel are updated to use the barrel for any references within the - barrel intself by using `../heroes`. Since they were moved into a new folder, they are also updated to add `../` - to module imports outside the barrel. +.alert.is-helpful + :marked + Do not attempt to reference the barrel index file from within the barrel. + These files are still imported individually as shown below. +makeTabs( - `cb-barrels/ts/app/heroes/hero.service.ts, - cb-barrels/ts/app/heroes/hero-detail.component.ts, + `cb-barrels/ts/app/heroes/hero-detail.component.ts, cb-barrels/ts/app/heroes/heroes.component.ts`, `imports, - imports, imports`, - `app/heroes/hero.service.ts, - app/heroes/hero-detail.component.ts, + `app/heroes/hero-detail.component.ts, app/heroes/heroes.component.ts` -) +) + +:marked + Since the `HeroService` was moved into a new folder, it's reference to + `mock-heroes` is updated to add `../`. + ++makeExample('cb-barrels/ts/app/heroes/hero.service.ts', 'imports', 'app/heroes/hero.service.ts') From beb3fe5eefc3da32b9391597b21d465d66295ec3 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Tue, 17 May 2016 14:55:10 -0600 Subject: [PATCH 07/41] docs(cb-barrels): Add heroes package to systemjs config --- public/docs/_examples/cb-barrels/ts/app/app.component.ts | 2 +- .../_examples/cb-barrels/ts/app/dashboard.component.ts | 2 +- public/docs/_examples/cb-barrels/ts/app/main.ts | 2 +- public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts | 2 +- public/docs/_examples/cb-barrels/ts/index.html | 7 +++++++ public/docs/ts/latest/cookbook/barrels.jade | 7 ++++++- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/public/docs/_examples/cb-barrels/ts/app/app.component.ts b/public/docs/_examples/cb-barrels/ts/app/app.component.ts index b8ff9cc9a0..926eafc1c9 100644 --- a/public/docs/_examples/cb-barrels/ts/app/app.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/app.component.ts @@ -1,7 +1,7 @@ // #docregion imports import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; -import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes/index'; +import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes'; import { DashboardComponent } from './dashboard.component'; @Component({ diff --git a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts index 3a6b327934..1239207374 100644 --- a/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/dashboard.component.ts @@ -1,7 +1,7 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; -import { Hero, HeroService } from './heroes/index'; +import { Hero, HeroService } from './heroes'; @Component({ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/app/main.ts b/public/docs/_examples/cb-barrels/ts/app/main.ts index a1baa78d94..09288fb174 100644 --- a/public/docs/_examples/cb-barrels/ts/app/main.ts +++ b/public/docs/_examples/cb-barrels/ts/app/main.ts @@ -1,7 +1,7 @@ // #docregion imports import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; -import { HeroService } from './heroes/index'; +import { HeroService } from './heroes'; import { AppComponent } from './app.component'; bootstrap(AppComponent, [ diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts index 544aa1d4a4..cfcffa5ce3 100644 --- a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts +++ b/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts @@ -1,5 +1,5 @@ // #docregion imports -import { Hero } from './heroes/index'; +import { Hero } from './heroes'; export var HEROES: Hero[] = [ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/index.html b/public/docs/_examples/cb-barrels/ts/index.html index 99dd3b6e07..127ee6ac5e 100644 --- a/public/docs/_examples/cb-barrels/ts/index.html +++ b/public/docs/_examples/cb-barrels/ts/index.html @@ -14,10 +14,17 @@ + + diff --git a/public/docs/ts/latest/cookbook/barrels.jade b/public/docs/ts/latest/cookbook/barrels.jade index 70b2312301..913a5984c9 100644 --- a/public/docs/ts/latest/cookbook/barrels.jade +++ b/public/docs/ts/latest/cookbook/barrels.jade @@ -42,8 +42,13 @@ include ../_util-fns +makeExample('cb-barrels/ts/app/heroes/index.ts', '', 'app/heroes/index.ts') :marked - Each of the files are now available as a single import. + The SystemJs module loader is not yet able to identify our new barrel, so + app/heroes is added manually as a package in index.html. ++makeExample('cb-barrels/ts/index.html', 'packages', 'index.html') +:marked + The files inside the barrel can now be imported through a single import. + :marked ## Importing a barrel From 91bb9d80ffe59e39b5d5753859707f4f96303d2d Mon Sep 17 00:00:00 2001 From: Eric Jimenez Date: Tue, 17 May 2016 12:24:37 -0400 Subject: [PATCH 08/41] fix(resources): use title key from firebase. Adjust layout a bit --- public/resources/css/module/_resources.scss | 4 ++-- public/resources/index.ejs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/resources/css/module/_resources.scss b/public/resources/css/module/_resources.scss index ce23ca3d73..f8b9fb3498 100644 --- a/public/resources/css/module/_resources.scss +++ b/public/resources/css/module/_resources.scss @@ -1,10 +1,10 @@ .resources { display: flex; justify-content: space-between; - flex-wrap: wrap; flex-direction: row-reverse; - @media(max-width: 400px) { + @media(max-width: 768px) { + justify-content: center; flex-direction: column-reverse; } diff --git a/public/resources/index.ejs b/public/resources/index.ejs index 51adecdc77..bb85fc7ddc 100644 --- a/public/resources/index.ejs +++ b/public/resources/index.ejs @@ -5,10 +5,10 @@

{{category}}

-
+
-

{{ subsectionName }}

-
From e855de5e2e4779563fcaf1bf1993df5b55f1e5f2 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Tue, 17 May 2016 17:13:11 -0600 Subject: [PATCH 09/41] docs(cb-barrels): Fix typo and use .filetree --- public/docs/ts/latest/cookbook/barrels.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/docs/ts/latest/cookbook/barrels.jade b/public/docs/ts/latest/cookbook/barrels.jade index 913a5984c9..e76b63c288 100644 --- a/public/docs/ts/latest/cookbook/barrels.jade +++ b/public/docs/ts/latest/cookbook/barrels.jade @@ -31,7 +31,7 @@ include ../_util-fns hero-detail.component.css hero-detail.component.html hero-detail.component.ts - hero-service.ts + hero.service.ts hero.ts heroes.component.css heroes.component.html @@ -48,7 +48,7 @@ include ../_util-fns :marked The files inside the barrel can now be imported through a single import. - + :marked ## Importing a barrel From 0646adafe7fed88d58c3cf85afe1423f590d01c6 Mon Sep 17 00:00:00 2001 From: Jim Cooper Date: Tue, 17 May 2016 19:23:45 -0600 Subject: [PATCH 10/41] docs(cb-barrels): reorganize into multiple barrels --- .../hero-detail.component.css | 0 .../hero-detail.component.html | 0 .../hero-detail.component.ts | 7 +- .../ts/app/heroes/heroes.component.ts | 5 +- .../cb-barrels/ts/app/heroes/index.ts | 5 +- .../heroes/{hero.ts => shared/hero.model.ts} | 0 .../app/heroes/{ => shared}/hero.service.ts | 2 +- .../cb-barrels/ts/app/heroes/shared/index.ts | 3 + .../ts/app/{ => heroes/shared}/mock-heroes.ts | 2 +- .../docs/_examples/cb-barrels/ts/index.html | 3 +- public/docs/ts/latest/cookbook/barrels.jade | 76 ++++++++++--------- 11 files changed, 56 insertions(+), 47 deletions(-) rename public/docs/_examples/cb-barrels/ts/app/heroes/{ => hero-detail}/hero-detail.component.css (100%) rename public/docs/_examples/cb-barrels/ts/app/heroes/{ => hero-detail}/hero-detail.component.html (100%) rename public/docs/_examples/cb-barrels/ts/app/heroes/{ => hero-detail}/hero-detail.component.ts (73%) rename public/docs/_examples/cb-barrels/ts/app/heroes/{hero.ts => shared/hero.model.ts} (100%) rename public/docs/_examples/cb-barrels/ts/app/heroes/{ => shared}/hero.service.ts (87%) create mode 100644 public/docs/_examples/cb-barrels/ts/app/heroes/shared/index.ts rename public/docs/_examples/cb-barrels/ts/app/{ => heroes/shared}/mock-heroes.ts (91%) diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.css similarity index 100% rename from public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.css rename to public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.css diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.html similarity index 100% rename from public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.html rename to public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.html diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.ts similarity index 73% rename from public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts rename to public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.ts index e6db3ae4bd..c945a8f6dd 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/hero-detail/hero-detail.component.ts @@ -1,14 +1,13 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { RouteParams } from '@angular/router-deprecated'; -import { HeroService } from './hero.service'; -import { Hero } from './hero'; +import { HeroService, Hero } from '../shared'; @Component({ // #enddocregion selector: 'my-hero-detail', - templateUrl: 'app/heroes/hero-detail.component.html', - styleUrls: ['app/heroes/hero-detail.component.css'] + templateUrl: 'app/heroes/hero-detail/hero-detail.component.html', + styleUrls: ['app/heroes/hero-detail/hero-detail.component.css'] }) export class HeroDetailComponent implements OnInit { hero: Hero; diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts index 41db767098..7bc3cfb000 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/heroes.component.ts @@ -1,9 +1,8 @@ // #docregion imports import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; -import { HeroService } from './hero.service'; -import { HeroDetailComponent } from './hero-detail.component' -import { Hero } from './hero'; +import { HeroService, Hero } from './shared'; +import { HeroDetailComponent } from './hero-detail/hero-detail.component' @Component({ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts index 8f98b1c560..9101d48411 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/index.ts @@ -1,5 +1,4 @@ // #docregion -export * from './hero'; -export * from './hero-detail.component'; -export * from './hero.service'; +export * from './hero-detail/hero-detail.component'; export * from './heroes.component'; +export * from './shared'; diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/hero.model.ts similarity index 100% rename from public/docs/_examples/cb-barrels/ts/app/heroes/hero.ts rename to public/docs/_examples/cb-barrels/ts/app/heroes/shared/hero.model.ts diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/hero.service.ts similarity index 87% rename from public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts rename to public/docs/_examples/cb-barrels/ts/app/heroes/shared/hero.service.ts index 2f4ef35fc8..11d60b97a6 100644 --- a/public/docs/_examples/cb-barrels/ts/app/heroes/hero.service.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/hero.service.ts @@ -1,6 +1,6 @@ // #docregion imports import { Injectable } from '@angular/core'; -import { HEROES } from '../mock-heroes'; +import { HEROES } from './mock-heroes'; @Injectable() export class HeroService { diff --git a/public/docs/_examples/cb-barrels/ts/app/heroes/shared/index.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/index.ts new file mode 100644 index 0000000000..27516fdedd --- /dev/null +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/index.ts @@ -0,0 +1,3 @@ +// #docregion +export * from './hero.model'; +export * from './hero.service'; diff --git a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/mock-heroes.ts similarity index 91% rename from public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts rename to public/docs/_examples/cb-barrels/ts/app/heroes/shared/mock-heroes.ts index cfcffa5ce3..014b7075d1 100644 --- a/public/docs/_examples/cb-barrels/ts/app/mock-heroes.ts +++ b/public/docs/_examples/cb-barrels/ts/app/heroes/shared/mock-heroes.ts @@ -1,5 +1,5 @@ // #docregion imports -import { Hero } from './heroes'; +import { Hero } from './hero.model'; export var HEROES: Hero[] = [ // #enddocregion diff --git a/public/docs/_examples/cb-barrels/ts/index.html b/public/docs/_examples/cb-barrels/ts/index.html index 127ee6ac5e..5cc8fa9acb 100644 --- a/public/docs/_examples/cb-barrels/ts/index.html +++ b/public/docs/_examples/cb-barrels/ts/index.html @@ -19,7 +19,8 @@ + + + + + + + + + + + Loading... + + diff --git a/public/docs/_examples/toh-6/ts/plnkr.json b/public/docs/_examples/toh-6/ts/plnkr.json new file mode 100644 index 0000000000..777d9ad1f1 --- /dev/null +++ b/public/docs/_examples/toh-6/ts/plnkr.json @@ -0,0 +1,9 @@ +{ + "description": "Tour of Heroes: Part 6", + "files":[ + "!**/*.d.ts", + "!**/*.js", + "!**/*.[1,2].*" + ], + "tags": ["tutorial", "tour", "heroes", "http"] +} diff --git a/public/docs/_examples/toh-6/ts/sample.css b/public/docs/_examples/toh-6/ts/sample.css new file mode 100644 index 0000000000..042f0494f6 --- /dev/null +++ b/public/docs/_examples/toh-6/ts/sample.css @@ -0,0 +1,8 @@ +button.delete-button{ + float:right; + background-color: gray !important; + color:white; +} + + + diff --git a/public/docs/ts/latest/tutorial/_data.json b/public/docs/ts/latest/tutorial/_data.json index 28d02b2ccb..22b7c4be4e 100644 --- a/public/docs/ts/latest/tutorial/_data.json +++ b/public/docs/ts/latest/tutorial/_data.json @@ -29,5 +29,10 @@ "title": "Routing", "intro": "We add the Angular Component Router and learn to navigate among the views", "nextable": true + }, + "toh-pt6": { + "title": "Http", + "intro": "We convert our service and components to use Http", + "nextable": true } } \ No newline at end of file diff --git a/public/docs/ts/latest/tutorial/toh-pt5.jade b/public/docs/ts/latest/tutorial/toh-pt5.jade index 1244b107ef..0afe4be3fc 100644 --- a/public/docs/ts/latest/tutorial/toh-pt5.jade +++ b/public/docs/ts/latest/tutorial/toh-pt5.jade @@ -669,6 +669,7 @@ figure.image-display .file index.html .file package.json .file styles.css + .file systemjs.config.json .file tsconfig.json .file typings.json :marked diff --git a/public/docs/ts/latest/tutorial/toh-pt6.jade b/public/docs/ts/latest/tutorial/toh-pt6.jade new file mode 100644 index 0000000000..5e0de751c9 --- /dev/null +++ b/public/docs/ts/latest/tutorial/toh-pt6.jade @@ -0,0 +1,350 @@ +include ../_util-fns + +:marked + # Http + + Our application has become a huge success and our stakeholders have expanded the vision to include integration with a hero api. + + The current solution limits us to a fixed set of heroes, but integration with a web server api will make our application much more flexible. We will also be able to add, edit and delete heroes. + + In this chapter we will connect our Angular 2 services to make http calls to our new api. +:marked + [Run the live example](/resources/live-examples/toh-6/ts/plnkr.html). + +.l-main-section +:marked + ## Where We Left Off + Before we continue with our Tour of Heroes, let’s verify that we have the following structure after adding our hero service + and hero detail component. If not, we’ll need to go back and follow the previous chapters. + +.filetree + .file angular2-tour-of-heroes + .children + .file app + .children + .file app.component.ts + .file app.component.css + .file dashboard.component.css + .file dashboard.component.html + .file dashboard.component.ts + .file hero.ts + .file hero-detail.component.css + .file hero-detail.component.html + .file hero-detail.component.ts + .file hero.service.ts + .file heroes.component.css + .file heroes.component.html + .file heroes.component.ts + .file main.ts + .file mock-heroes.ts + .file node_modules ... + .file typings ... + .file index.html + .file package.json + .file styles.css + .file systemjs.config.json + .file tsconfig.json + .file typings.json +:marked + ### Keep the app transpiling and running + Open a terminal/console window and enter the following command to + start the TypeScript compiler, start the server, and watch for changes: + +code-example(format="." language="bash"). + npm start + +:marked + The application runs and updates automatically as we continue to build the Tour of Heroes. + +.l-main-section +:marked + ## Prepare for Http + + `Http` is ***not*** a core Angular module. + It's Angular's optional approach to web access and it exists as a separate add-on module called `@angular/http`, + shipped in a separate script file as part of the Angular npm package. + + Fortunately we're ready to import from `@angular/http` because `systemjs.config` configured *SystemJS* to load that library when we need it. + +:marked + ### Register (provide) *http* services + Our app will depend upon the Angular `http` service which itself depends upon other supporting services. + The `HTTP_PROVIDERS` array from `@angular/http` library holds providers for the complete set of http services. + + We should be able to access these services from anywhere in the application. + So we register them in the `bootstrap` method of `main.ts` where we + launch the application and its root `AppComponent`. + ++makeExample('toh-6/ts/app/main.ts','v1','app/main.ts (v1)')(format='.') +:marked + Notice that we supply the `HTTP_PROVIDERS` in an array as the second parameter to the `bootstrap` method. + This has the same effect the `providers` array in `@Component` metadata. + +.l-main-section +:marked + ## Simulating the web api + + We generally recommend registering application-wide services in the root `AppComponent` *providers*. + Here we're registering in `main` for a special reason. + + Our application is in the early stages of development and far from ready for production. + We don't even have a web server that can handle requests for heroes. + Until we do, *we'll have to fake it*. + + We're going to *trick* the http client into fetching and saving data from + a demo/development service, the *in-memory web api*. + + The application itself doesn't need to know and shouldn't know about this. + So we'll slip the *in-memory web api* into the configuration *above* the `AppComponent`. + + Here is a version of `main` that performs this trick ++makeExample('toh-6/ts/app/main.ts', 'final', 'app/main.ts (final)')(format=".") + +:marked + We're replacing the default `XHRBackend`, the service that talks to the remote server, + with the *in-memory web api* service after priming it with the following `in-memory-data.service.ts` file: ++makeExample('toh-6/ts/app/in-memory-data.service.ts', null, 'app/in-memory-data.service.ts')(format=".") +:marked + This file replaces the `mock-heroes.ts` which is now safe to delete. + +.alert.is-helpful + :marked + This chaper is an introduction to the Angular http client. + Please don't be distracted by the details of this backend substitution. Just follow along with the example. + + Learn more later about the *in-memory web api* in the [Http chapter](../guide/server-communication.html#!#in-mem-web-api). + Remember, the *in-memory web api* is only useful in the early stages of development and for demonstrations such as this Tour of Heroes. + Skip it when you have a real web api server. + + +.l-main-section +:marked + ## Heroes and Http + + Look at our current `HeroService` implementation ++makeExample('toh-4/ts/app/hero.service.ts', 'get-heroes', 'app/hero.service.ts (getHeroes - old)')(format=".") +:marked + We returned a promise resolved with mock heroes. + It may have seemed like overkill at the time, but we were anticipating the + day when we fetched heroes with an http client and we knew that would have to be an asynchronous operation. + + That day has arrived! Let's convert `getHeroes()` to use Angular's `Http` client: + ++makeExample('toh-6/ts/app/hero.service.ts', 'get-heroes', 'app/hero.service.ts (getHeroes using Http)')(format=".") + +:marked + ### Http Promise + + We're still returning a promise but we're creating it differently. + + The Angular `http.get` returns an RxJS `Observable`. + *Observables* are a powerful way to manage asynchronous data flows. + We'll learn about `Observables` *later*. + + For *now* we get back on familiar ground by immediately converting that `Observable` to a `Promise` using the `toPromise` operator. ++makeExample('toh-6/ts/app/hero.service.ts', 'to-promise')(format=".") +:marked + Unfortunately, the Angular `Observable` doesn't have a `toPromise` operator ... not out of the box. + The Angular `Observable` is a bare-bones implementation. + + There are scores of operators like `toPromise` that extend `Observable` with useful capabilities. + If we want those capabilities, we have to add the operators ourselves. + That's as easy as importing them from the RxJS library like this: ++makeExample('toh-6/ts/app/hero.service.ts', 'rxjs')(format=".") + +:marked + ### Extracting the data in the *then* callback + In the *promise*'s `then` callback we call the `json` method of the http `Response` to extract the + data within the response. ++makeExample('toh-6/ts/app/hero.service.ts', 'to-data')(format=".") +:marked + That object returned by `json` has a single `data` property. + The `data` property holds the array of *heroes* that the caller really wants. + So we grab that array and return it as the resolved promise value. + +.alert.is-important + :marked + Pay close attention to the shape of the data returned by the server. + This particular *in-memory web api* example happens to return an object with a `data` property. + Your api might return something else. + + Adjust the code to match *your web api*. +:marked + The caller is unaware of these machinations. It receives a promise of *heroes* just as it did before. + It has no idea that we fetched the heroes from the server. + It knows nothing of the twists and turns required to turn the http response into heroes. + Such is the beauty and purpose of delegating data access to a service like this `HeroService`. +:marked + ### Error Handling + + At the end of `getHeroes` we `catch` server failures and pass them to an error handler: ++makeExample('toh-6/ts/app/hero.service.ts', 'catch')(format=".") +:marked + This is a critical step! + We must anticipate http failures as they happen frequently for reasons beyond our control. + ++makeExample('toh-6/ts/app/hero.service.ts', 'error-handler', 'app/hero.service.ts (Error handler)')(format=".") +:marked + In this demo service we log the error to the console; we should do better in real life. + + We've also decided to return a user friendly form of the error to + to the caller in a rejected promise so that the caller can display a proper error message to the user. + + ### Promises are Promises + Although we made significant *internal* changes to `getHeroes()`, the public signature did not change. + We still return a promise. We won't have to update any of the components that call `getHeroes()`. + +.l-main-section +:marked + ## Add, Edit, Delete + + Our stakeholders are incredibly pleased with the added flexibility from the api integration, but it doesn't stop there. Next we want to add the capability to add, edit and delete heroes. + + We'll complete `HeroService` by creating `post`, `put` and `delete` http calls to meet our new requirements. + +:marked + ### Post + + We are using `post` to add new heroes. Post requests require a little bit more setup than Get requests, but the format is as follows: + ++makeExample('toh-6/ts/app/hero.service.ts', 'post-hero', 'app/hero.service.ts (post hero)')(format=".") + +:marked + Now we create a header and set the content type to `application/json`. We'll call `JSON.stringify` before we post to convert the hero object to a string. + + ### Put + + `put` is used to edit a specific hero, but the structure is very similar to a `post` request. The only difference is that we have to change the url slightly by appending the id of the hero we want to edit. + ++makeExample('toh-6/ts/app/hero.service.ts', 'put-hero', 'app/hero.service.ts (put hero)')(format=".") + +:marked + ### Delete + `delete` is used to delete heroes and the format is identical to `put` except for the function name. + ++makeExample('toh-6/ts/app/hero.service.ts', 'delete-hero', 'app/hero.service.ts (delete hero)')(format=".") + +:marked + We add a `catch` to handle our errors for all three cases. + +: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. + ++makeExample('toh-6/ts/app/hero.service.ts', 'save', 'app/hero.service.ts (save hero)')(format=".") + +:marked + After these additions our `HeroService` looks like this: + ++makeExample('toh-6/ts/app/hero.service.ts', null, 'app/hero.service.ts')(format=".") + +.l-main-section +:marked + ## Updating Components + + Loading heroes using `Http` required no changes outside of `HeroService`, but we added a few new features as well. In the following section we will update our components to use our new methods to add, edit and delete heroes. + + ### Add/Edit + We already have `HeroDetailComponent` for viewing details about a specific hero. Add and Edit are natural extensions of the detail view, so we are able to reuse `DetailHeroComponent` with a few tweaks. The original component was created to render existing data, but to add new data we have to initialize the `hero` property to an empty `Hero` object. + ++makeExample('toh-6/ts/app/hero-detail.component.ts', 'ngOnInit', 'app/hero-detail.component.ts (ngOnInit)')(format=".") + +:marked + In order to differentiate between add and edit we are adding a check to see if an id is passed in the url. If the id is absent we bind `HeroDetailComponent` to an empty `Hero` object. In either case, any edits made through the UI will be bound back to the same `hero` property. + + The next step is to add a save method to `HeroDetailComponent` and call the corresponding save method in `HeroesService`. + ++makeExample('toh-6/ts/app/hero-detail.component.ts', 'save', 'app/hero-detail.component.ts (save)')(format=".") + +:marked + The same save method is used for both add and edit since `HeroService` will know when to call `post` vs `put` based on the state of the `Hero` object. + + Earlier we used the `save()` method to return a promise, so when the promise resolves, we call `emit` to notify `HeroesComponent` that we just added or modified a hero. `HeroesComponent` is listening for this notification and will automatically refresh the list of heroes to include our recent updates. + +.l-sub-section + :marked + The `emit` "handshake" between `HeroDetailComponent` and `HeroesComponent` is an example of component to component communication. This is a topic for another day, but we have detailed information in our Component Interaction Cookbook + +:marked + Here is `HeroDetailComponent` with the added save button. + +figure.image-display + img(src='/resources/images/devguide/toh/hero-details-save-button.png' alt="Hero Details With Save Button") + +:marked + ### Delete + + We have added the option to delete hereos from `HeroesComponent`. `HeroService` will delete the hero, but we still have to filter out the deleted hero from the list to update the view. + ++makeExample('toh-6/ts/app/heroes.component.ts', 'delete', 'app/heroes.component.ts (delete)')(format=".") + +:marked + Here is `HeroesComponent` with the delete button. + +figure.image-display + img(src='/resources/images/devguide/toh/heroes-list-delete-button.png' alt="Heroes List With Delete Button") + +:marked + ### Review the App Structure + Let’s verify that we have the following structure after all of our good refactoring in this chapter: + +.filetree + .file angular2-tour-of-heroes + .children + .file app + .children + .file app.component.ts + .file app.component.css + .file dashboard.component.css + .file dashboard.component.html + .file dashboard.component.ts + .file hero.ts + .file hero-detail.component.css + .file hero-detail.component.html + .file hero-detail.component.ts + .file hero.service.ts + .file heroes.component.css + .file heroes.component.html + .file heroes.component.ts + .file main.ts + .file hero-data.service.ts + .file node_modules ... + .file typings ... + .file index.html + .file package.json + .file styles.css + .file sample.css + .file systemjs.config.json + .file tsconfig.json + .file typings.json + +.l-main-section +:marked + ## Home Stretch + + We are at the end of our journey for now, but we have accomplished a lot. + - We added the necessary dependencies to use Http in our application. + - We refactored HeroService to load heroes from an api. + - We extended HeroService to support post, put and delete calls. + - We updated our components to allow adding, editing and deleting of heroes. + - We configured an in-memory web api. + + Below is a summary of the files we changed. + ++makeTabs( + `toh-6/ts/app/app.component.ts, + toh-6/ts/app/heroes.component.ts, + toh-6/ts/app/heroes.component.html, + toh-6/ts/app/hero-detail.component.ts, + toh-6/ts/app/hero-detail.component.html, + toh-6/ts/app/hero.service.ts`, + null, + `app.comp...ts, + heroes.comp...ts, + heroes.comp...html, + hero-detail.comp...ts, + hero-detail.comp...html, + hero.service.ts` +) + diff --git a/public/resources/images/devguide/toh/hero-details-save-button.png b/public/resources/images/devguide/toh/hero-details-save-button.png new file mode 100644 index 0000000000000000000000000000000000000000..91c201a31078bf463f2ba3bb994abda37988525d GIT binary patch literal 17969 zcmeFZV~}LQ*FMGd6@!Dpf&l^of|C#zRs;e92K|0RLP30MD*1`Gzc0KkgoNZJ zgoFs>9qmjltWAJ`C=!hH^{FIiD8>v7^!3N4sVQL`-4w&aqZRdg2m7Y`1__4rhY51i zwYB#!5cdZCk-a-d`k)Hw&jY6<@83NZOPjqv(b#G;992m<+a3de-6Sm?m_R{^A>(th z6|=K{7#{xFV%b4}qv6BOSsT zO98EeNFcUAgy+B;X!);=V@6Q&w?K~3g=6>mFAj?IZ}lmzCir(sK(up|FmUk~3@2rx zW5GH?B2F^6Gqf>KFr+hMFsL(~FtMi=t0w!Sa2}&8qnVVNB~!422(hX3bMUq1H<2`p zi}f?pYsiW9kM+#~6~m*LAr|pL2FRG9aK#}`>W%g3S4{QwZ3Q7pWsdaK`5=G>4N(TC zPjEv(_*y}P+8o0mMIr6Oo4t<+hU;aUT7wzfvokW(?fm`vYQzEs{YwH7+Kc@4_0@gy z_0<~{@C15r!4D5a;%2cIZH0vJeIIfxl+~TpWu!Tc>}==^jO`3f=-h4WzwZ+e5Vt$$ zw`gPHY(U^{V{Pli>CQv+9}CWJ`JbAeh~Pga&Q?4`>N4^KLUxWO1gvx{bPPniFa!hy z+>XYkoQlGt|D*c%6%UcQv$H)XJ-wTo8=V_7ot>i@JtGGP2R#E5Jrfh{w*{?}hpn@L zJFTq~@qan_pMHc*oQxbT?42#_YzhAPH88YuapoZ+`q$9^di_^FP24U1cT2WT|6^F+ z1El{~LeEIYK>xpde^=%Hr{$Ela5u457q+l5v32@xgO`bwgZn@B|Cf^g-Qs_%sqx=x zvN8Ynn*Xijf7Ilr|2KgDHlY8C)_=6$;o^nirvG1|=Y>hfDdq6y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3;ck^!@Rge@d6C)PFA5N6T;ZUTNdEqnomtb$`oFwgPUp$27v*5W*USl zYGmrn!d-G!2#Dnor=}AXQl@<>L*+lf2D5Qz7sRrZH;^G+XsW1G9l!o@$2((fVNey$h@&Lhv@D?_lMpcE2&CVlJ@2neL}-+uwTJJ=Qf zjLn`Np_BpVZgRjNW+Ad&0s|*>u7;2~gm`>L2%J6ne36Bi;-(7+^by$7wiH$tK*Pbo zwQ2eS)`y+B*EaJ!-Dz2c5b?a2fa@6vPYMrzt!SS3yfZ|4%Ist)R%A%ZU5RZZSYwF| z(-^TF@!nxHWvb$QGf@t6lY?DjFO(A{@)bfvfc8d7cM#2;#Mh=X?5F%jLuNLd;>jy}6Jssrf zfQOHdyxU+_YH#<<1aEo~5D?H!rtdb$`anY?yr-H=`>tm@9bW3{R!%n+yCqn&qni*X zFamualLG3!8zyTM0z39W|S?pe*?;KZKv=_$Qubv%juI4}ak1%W~I84MSbSr0~l z5wM1U%aFk>x7=dQ{t=hvEOv}I;9WpryU3uoeoH)u+maQds;SL~CIr*&y`q$qs9_aT+7g7X<9uO%N3g_kSj8%Rdqw?luUV zZLvehabN`ci-6r^(BFzVA0xmB3@-%iS|$uHQ&<~DfDy0<0VV@`(Br&}fD<9WWZ*=N z$)+#@_8`DyU=Mnnml1Fx1egq*s4>|TM!+5fm<;SekMlADPJ{rHffF?*o5Bd#g8-9( sJ?L>>M!<;>U@~x`#$;0%0ecYm|Kv%2NH=R_i~s-t07*qoM6N<$f{R>(<^TWy literal 0 HcmV?d00001 diff --git a/public/resources/images/devguide/toh/heroes-list-delete-button.png b/public/resources/images/devguide/toh/heroes-list-delete-button.png new file mode 100644 index 0000000000000000000000000000000000000000..da87a20e4a2016a5786bf2da4901b79d769ace8a GIT binary patch literal 17009 zcmb`vRa{)bw(g5`pn(95J2Z_;aCf)ht_d!|U4uKpU4wgq2X~j?n&3`wg6nP8+IQ`> z@80*E^Kkm1f3xQtqpD`r%lEHuR7WT)N~0nZBE!JIpvu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p-ev=e0L5nk00ygKs)0dwz6=O7zkb@>eEIXu3gY!dkT9H2(|;Bv zK~G2EgQ3c+3*!tbPJ@L>AH$*7_^(GLjQr2Up*zW4WC8whePUka(TLDrU>@LDI=l3I zAiNmn9YdX|Mgny27J9BA#(&dJ6Fyc|UPNY-=-^{7!#jT) z6drCE3m(CPt4)(rwYRhk|4_{egV%mS2V?!C(D*h5+A|oCR9~Ko0r)*a04Im(L_Y%E zW9NbE76n6hl-JcmQb%6Z?*DH!QWhm#0DbB(Mw;mBArVo$M6D1C5D;o10N^y35-C`M nUeA#PF;PR$O@KkbM?Y$#11{qYwc^)*D3Fy@l=v=Y82JAH8U}Fr literal 0 HcmV?d00001 From e91659ac13ce30a3e5f377743df6641cf1c31a0b Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Thu, 19 May 2016 00:30:30 -0700 Subject: [PATCH 16/41] docs(tutorial/ts): delete tutorial sample in favor of toh-6 --- .../_examples/toh-4/ts/app/mock-heroes.ts | 20 +-- .../_examples/toh-5/ts/app/mock-heroes.ts | 22 ++-- public/docs/_examples/toh-6/e2e-spec.js | 114 ++++++++++++++++-- .../toh-6/ts/app/in-memory-data.service.ts | 14 ++- public/docs/_examples/tutorial/e2e-spec.js | 111 ----------------- .../tutorial/ts/app/app.component.css | 28 ----- .../tutorial/ts/app/app.component.ts | 31 ----- .../tutorial/ts/app/dashboard.component.css | 60 --------- .../tutorial/ts/app/dashboard.component.html | 8 -- .../tutorial/ts/app/dashboard.component.ts | 25 ---- .../tutorial/ts/app/hero-detail.component.css | 29 ----- .../ts/app/hero-detail.component.html | 10 -- .../tutorial/ts/app/hero-detail.component.ts | 27 ----- .../_examples/tutorial/ts/app/hero.service.ts | 16 --- public/docs/_examples/tutorial/ts/app/hero.ts | 4 - .../tutorial/ts/app/heroes.component.css | 59 --------- .../tutorial/ts/app/heroes.component.html | 14 --- .../tutorial/ts/app/heroes.component.ts | 32 ----- public/docs/_examples/tutorial/ts/app/main.ts | 10 -- .../_examples/tutorial/ts/app/mock-heroes.ts | 14 --- .../_examples/tutorial/ts/example-config.json | 0 public/docs/_examples/tutorial/ts/index.html | 26 ---- public/docs/_examples/tutorial/ts/plnkr.json | 8 -- public/docs/ts/latest/tutorial/index.jade | 2 +- 24 files changed, 134 insertions(+), 550 deletions(-) delete mode 100644 public/docs/_examples/tutorial/e2e-spec.js delete mode 100644 public/docs/_examples/tutorial/ts/app/app.component.css delete mode 100644 public/docs/_examples/tutorial/ts/app/app.component.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/dashboard.component.css delete mode 100644 public/docs/_examples/tutorial/ts/app/dashboard.component.html delete mode 100644 public/docs/_examples/tutorial/ts/app/dashboard.component.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/hero-detail.component.css delete mode 100644 public/docs/_examples/tutorial/ts/app/hero-detail.component.html delete mode 100644 public/docs/_examples/tutorial/ts/app/hero-detail.component.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/hero.service.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/hero.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/heroes.component.css delete mode 100644 public/docs/_examples/tutorial/ts/app/heroes.component.html delete mode 100644 public/docs/_examples/tutorial/ts/app/heroes.component.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/main.ts delete mode 100644 public/docs/_examples/tutorial/ts/app/mock-heroes.ts delete mode 100644 public/docs/_examples/tutorial/ts/example-config.json delete mode 100644 public/docs/_examples/tutorial/ts/index.html delete mode 100644 public/docs/_examples/tutorial/ts/plnkr.json diff --git a/public/docs/_examples/toh-4/ts/app/mock-heroes.ts b/public/docs/_examples/toh-4/ts/app/mock-heroes.ts index 35fa5c67a8..ddd36d7868 100644 --- a/public/docs/_examples/toh-4/ts/app/mock-heroes.ts +++ b/public/docs/_examples/toh-4/ts/app/mock-heroes.ts @@ -2,15 +2,15 @@ import { Hero } from './hero'; export var HEROES: Hero[] = [ - {"id": 11, "name": "Mr. Nice"}, - {"id": 12, "name": "Narco"}, - {"id": 13, "name": "Bombasto"}, - {"id": 14, "name": "Celeritas"}, - {"id": 15, "name": "Magneta"}, - {"id": 16, "name": "RubberMan"}, - {"id": 17, "name": "Dynama"}, - {"id": 18, "name": "Dr IQ"}, - {"id": 19, "name": "Magma"}, - {"id": 20, "name": "Tornado"} + {id: 11, name: 'Mr. Nice'}, + {id: 12, name: 'Narco'}, + {id: 13, name: 'Bombasto'}, + {id: 14, name: 'Celeritas'}, + {id: 15, name: 'Magneta'}, + {id: 16, name: 'RubberMan'}, + {id: 17, name: 'Dynama'}, + {id: 18, name: 'Dr IQ'}, + {id: 19, name: 'Magma'}, + {id: 20, name: 'Tornado'} ]; // #enddocregion diff --git a/public/docs/_examples/toh-5/ts/app/mock-heroes.ts b/public/docs/_examples/toh-5/ts/app/mock-heroes.ts index cdcba35097..ddd36d7868 100644 --- a/public/docs/_examples/toh-5/ts/app/mock-heroes.ts +++ b/public/docs/_examples/toh-5/ts/app/mock-heroes.ts @@ -2,15 +2,15 @@ import { Hero } from './hero'; export var HEROES: Hero[] = [ - {"id": 11, "name": "Mr. Nice"}, - {"id": 12, "name": "Narco"}, - {"id": 13, "name": "Bombasto"}, - {"id": 14, "name": "Celeritas"}, - {"id": 15, "name": "Magneta"}, - {"id": 16, "name": "RubberMan"}, - {"id": 17, "name": "Dynama"}, - {"id": 18, "name": "Dr IQ"}, - {"id": 19, "name": "Magma"}, - {"id": 20, "name": "Tornado"} + {id: 11, name: 'Mr. Nice'}, + {id: 12, name: 'Narco'}, + {id: 13, name: 'Bombasto'}, + {id: 14, name: 'Celeritas'}, + {id: 15, name: 'Magneta'}, + {id: 16, name: 'RubberMan'}, + {id: 17, name: 'Dynama'}, + {id: 18, name: 'Dr IQ'}, + {id: 19, name: 'Magma'}, + {id: 20, name: 'Tornado'} ]; -// #enddocregion \ No newline at end of file +// #enddocregion diff --git a/public/docs/_examples/toh-6/e2e-spec.js b/public/docs/_examples/toh-6/e2e-spec.js index 02d5b2a698..d5823b9add 100644 --- a/public/docs/_examples/toh-6/e2e-spec.js +++ b/public/docs/_examples/toh-6/e2e-spec.js @@ -16,7 +16,7 @@ describe('TOH Http Chapter', function () { myHeroesHref: hrefEles.get(1), myHeroesParent: element(by.css('my-app my-heroes')), allHeroes: element.all(by.css('my-app my-heroes li .hero-element')), - + firstDeleteButton: element.all(by.buttonText('Delete')).get(0), addButton: element.all(by.buttonText('Add New Hero')).get(0), @@ -28,21 +28,21 @@ describe('TOH Http Chapter', function () { it('should be able to add a hero from the "Heroes" view', function(){ var page = getPageStruct(); var heroCount; - + page.myHeroesHref.click().then(function() { browser.waitForAngular(); heroCount = page.allHeroes.count(); - expect(heroCount).toBe(4, 'should show 4'); + expect(heroCount).toBe(10, 'should show 10'); }).then(function() { return page.addButton.click(); }).then(function(){ return save(page,'','The New Hero'); }).then(function(){ browser.waitForAngular(); - + heroCount = page.allHeroes.count(); - expect(heroCount).toBe(5, 'should show 5'); - + expect(heroCount).toBe(11, 'should show 11'); + var newHero = element(by.xpath('//span[@class="hero-element" and contains(text(),"The New Hero")]')); expect(newHero).toBeDefined(); }); @@ -51,17 +51,17 @@ describe('TOH Http Chapter', function () { it('should be able to delete hero from "Heroes" view', function(){ var page = getPageStruct(); var heroCount; - + page.myHeroesHref.click().then(function() { browser.waitForAngular(); heroCount = page.allHeroes.count(); - expect(heroCount).toBe(4, 'should show 4'); + expect(heroCount).toBe(10, 'should show 10'); }).then(function() { return page.firstDeleteButton.click(); }).then(function(){ browser.waitForAngular(); heroCount = page.allHeroes.count(); - expect(heroCount).toBe(3, 'should show 3'); + expect(heroCount).toBe(9, 'should show 9'); }); }); @@ -71,7 +71,7 @@ describe('TOH Http Chapter', function () { var heroEle = page.topHeroes.get(2); var heroDescrEle = heroEle.element(by.css('h4')); var heroDescr; - + return heroDescrEle.getText().then(function(text) { heroDescr = text; return heroEle.click(); @@ -89,10 +89,10 @@ describe('TOH Http Chapter', function () { it('should be able to save details from "Heroes" view', function () { var page = getPageStruct(); - + var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); var heroEle, heroDescr; - + page.myHeroesHref.click().then(function() { expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); @@ -130,4 +130,94 @@ describe('TOH Http Chapter', function () { return saveButtonEle.click(); }); } + + it('should be able to see the start screen', function () { + var page = getPageStruct(); + expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); + expect(page.myDashboardHref.getText()).toEqual("Dashboard"); + expect(page.myHeroesHref.getText()).toEqual("Heroes"); + }); + + it('should be able to see dashboard choices', function () { + var page = getPageStruct(); + expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices"); + }); + + it('should be able to toggle the views', function () { + var page = getPageStruct(); + + expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); + expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown"); + return page.myDashboardHref.click(); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); + }); + + }); + + it('should be able to edit details from "Dashboard" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); + var heroEle = page.topHeroes.get(3); + var heroDescrEle = heroEle.element(by.css('h4')); + var heroDescr; + return heroDescrEle.getText().then(function(text) { + heroDescr = text; + return heroEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-foo'); + }).then(function() { + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); + expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); + }); + }); + + it('should be able to edit details from "Heroes" view', function () { + var page = getPageStruct(); + expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); + var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); + var heroEle, heroDescr; + page.myHeroesHref.click().then(function() { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); + heroEle = page.allHeroes.get(2); + return heroEle.getText(); + }).then(function(text) { + // remove leading 'id' from the element + heroDescr = text.substr(text.indexOf(' ')+1); + return heroEle.click(); + }).then(function() { + expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); + return viewDetailsButtonEle.click(); + }).then(function() { + return editDetails(page, heroDescr, '-bar'); + }).then(function() { + expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); + expect(heroEle.getText()).toContain(heroDescr + '-bar'); + expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); + }); + }); + + function editDetails(page, origValue, textToAdd) { + expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); + expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); + expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); + var inputEle = page.heroDetail.element(by.css('input')); + expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); + var buttons = page.heroDetail.all(by.css('button')); + var backButtonEle = buttons.get(0); + var saveButtonEle = buttons.get(1); + expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); + expect(saveButtonEle.isDisplayed()).toBe(true, 'should be able to see the save button'); + var detailTextEle = page.heroDetail.element(by.css('div h2')); + expect(detailTextEle.getText()).toContain(origValue); + return sendKeys(inputEle, textToAdd).then(function () { + expect(detailTextEle.getText()).toContain(origValue + textToAdd); + return saveButtonEle.click(); + }); + } + }); diff --git a/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts b/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts index 0edb70f37b..791b6ae2c5 100644 --- a/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts +++ b/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts @@ -2,10 +2,16 @@ export class InMemoryDataService { createDb() { let heroes = [ - { id: 1, name: 'Windstorm' }, - { id: 2, name: 'Bombasto' }, - { id: 3, name: 'Magneta' }, - { id: 4, name: 'Tornado' } + {id: 11, name: 'Mr. Nice'}, + {id: 12, name: 'Narco'}, + {id: 13, name: 'Bombasto'}, + {id: 14, name: 'Celeritas'}, + {id: 15, name: 'Magneta'}, + {id: 16, name: 'RubberMan'}, + {id: 17, name: 'Dynama'}, + {id: 18, name: 'Dr IQ'}, + {id: 19, name: 'Magma'}, + {id: 20, name: 'Tornado'} ]; return {heroes}; } diff --git a/public/docs/_examples/tutorial/e2e-spec.js b/public/docs/_examples/tutorial/e2e-spec.js deleted file mode 100644 index f35fcd1287..0000000000 --- a/public/docs/_examples/tutorial/e2e-spec.js +++ /dev/null @@ -1,111 +0,0 @@ -describe('Tutorial', function () { - - beforeAll(function () { - browser.get(''); - }); - - - function getPageStruct() { - hrefEles = element.all(by.css('my-app a')); - - return { - hrefs: hrefEles, - myDashboardHref: hrefEles.get(0), - myDashboardParent: element(by.css('my-app my-dashboard')), - topHeroes: element.all(by.css('my-app my-dashboard .module.hero')), - - myHeroesHref: hrefEles.get(1), - myHeroesParent: element(by.css('my-app my-heroes')), - allHeroes: element.all(by.css('my-app my-heroes li')), - - heroDetail: element(by.css('my-app my-hero-detail')) - } - } - - it('should be able to see the start screen', function () { - var page = getPageStruct(); - expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); - expect(page.myDashboardHref.getText()).toEqual("Dashboard"); - expect(page.myHeroesHref.getText()).toEqual("Heroes"); - }); - - it('should be able to see dashboard choices', function () { - var page = getPageStruct(); - expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices"); - }); - - it('should be able to toggle the views', function () { - var page = getPageStruct(); - - expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); - expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown"); - return page.myDashboardHref.click(); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); - }); - - }); - - it('should be able to edit details from "Dashboard" view', function () { - var page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); - var heroEle = page.topHeroes.get(3); - var heroDescrEle = heroEle.element(by.css('h4')); - var heroDescr; - return heroDescrEle.getText().then(function(text) { - heroDescr = text; - return heroEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-foo'); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); - expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); - }); - }); - - it('should be able to edit details from "Heroes" view', function () { - var page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); - var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); - var heroEle, heroDescr; - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); - heroEle = page.allHeroes.get(2); - return heroEle.getText(); - }).then(function(text) { - // remove leading 'id' from the element - heroDescr = text.substr(text.indexOf(' ')+1); - return heroEle.click(); - }).then(function() { - expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); - return viewDetailsButtonEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-bar'); - }).then(function() { - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); - expect(heroEle.getText()).toContain(heroDescr + '-bar'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); - }); - }); - - function editDetails(page, origValue, textToAdd) { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); - expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); - var inputEle = page.heroDetail.element(by.css('input')); - expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); - var backButtonEle = page.heroDetail.element(by.css('button')); - expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); - var detailTextEle = page.heroDetail.element(by.css('div h2')); - expect(detailTextEle.getText()).toContain(origValue); - return sendKeys(inputEle, textToAdd).then(function () { - expect(detailTextEle.getText()).toContain(origValue + textToAdd); - return backButtonEle.click(); - }); - } - -}); diff --git a/public/docs/_examples/tutorial/ts/app/app.component.css b/public/docs/_examples/tutorial/ts/app/app.component.css deleted file mode 100644 index 246b8c875b..0000000000 --- a/public/docs/_examples/tutorial/ts/app/app.component.css +++ /dev/null @@ -1,28 +0,0 @@ -nav a { - padding: 5px 10px; - text-decoration: none; - margin-top: 10px; - display: inline-block; - background-color: #eee; - border-radius: 4px; -} -nav a:visited, a:link { - color: #607D8B; -} -nav a:hover { - color: #039be5; - background-color: #CFD8DC; -} -nav a.router-link-active { - color: #039be5; -} -h1 { - font-size: 1.2em; - color: #999; - margin-bottom: 0; -} -h2 { - font-size: 2em; - margin-top: 0; - padding-top: 0; -} \ No newline at end of file diff --git a/public/docs/_examples/tutorial/ts/app/app.component.ts b/public/docs/_examples/tutorial/ts/app/app.component.ts deleted file mode 100644 index 8b0e0ad8da..0000000000 --- a/public/docs/_examples/tutorial/ts/app/app.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component } from '@angular/core'; -import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; - -import { HeroesComponent } from './heroes.component'; -import { HeroDetailComponent } from './hero-detail.component'; -import { DashboardComponent } from './dashboard.component'; -import { HeroService } from './hero.service'; - -@Component({ - selector: 'my-app', - template: ` -

{{title}}

- - - `, - styleUrls: ['app/app.component.css'], - directives: [ROUTER_DIRECTIVES], - providers: [HeroService] -}) -@RouteConfig([ - // {path: '/', redirectTo: ['Dashboard'] }, - {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true}, - {path: '/heroes', name: 'Heroes', component: HeroesComponent}, - {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent} -]) -export class AppComponent { - title = 'Tour of Heroes'; -} diff --git a/public/docs/_examples/tutorial/ts/app/dashboard.component.css b/public/docs/_examples/tutorial/ts/app/dashboard.component.css deleted file mode 100644 index d000c0c77e..0000000000 --- a/public/docs/_examples/tutorial/ts/app/dashboard.component.css +++ /dev/null @@ -1,60 +0,0 @@ -[class*='col-'] { - float: left; -} -*, *:after, *:before { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -h3 { - text-align: center; margin-bottom: 0; -} -[class*='col-'] { - padding-right: 20px; - padding-bottom: 20px; -} -[class*='col-']:last-of-type { - padding-right: 0; -} -.grid { - margin: 0; -} -.col-1-4 { - width: 25%; -} -.module { - padding: 20px; - text-align: center; - color: #eee; - max-height: 120px; - min-width: 120px; - background-color: #607D8B; - border-radius: 2px; -} -h4 { - position: relative; -} -.module:hover { - background-color: #EEE; - cursor: pointer; - color: #607d8b; -} -.grid-pad { - padding: 10px 0; -} -.grid-pad > [class*='col-']:last-of-type { - padding-right: 20px; -} -@media (max-width: 600px) { - .module { - font-size: 10px; - max-height: 75px; } -} -@media (max-width: 1024px) { - .grid { - margin: 0; - } - .module { - min-width: 60px; - } -} diff --git a/public/docs/_examples/tutorial/ts/app/dashboard.component.html b/public/docs/_examples/tutorial/ts/app/dashboard.component.html deleted file mode 100644 index dfec651c4a..0000000000 --- a/public/docs/_examples/tutorial/ts/app/dashboard.component.html +++ /dev/null @@ -1,8 +0,0 @@ -

Top Heroes

-
-
-
-

{{hero.name}}

-
-
-
diff --git a/public/docs/_examples/tutorial/ts/app/dashboard.component.ts b/public/docs/_examples/tutorial/ts/app/dashboard.component.ts deleted file mode 100644 index f08e40a6e1..0000000000 --- a/public/docs/_examples/tutorial/ts/app/dashboard.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router-deprecated'; - -import { Hero } from './hero'; -import { HeroService } from './hero.service'; - -@Component({ - selector: 'my-dashboard', - templateUrl: 'app/dashboard.component.html', - styleUrls: ['app/dashboard.component.css'] -}) -export class DashboardComponent implements OnInit { - heroes: Hero[] = []; - - constructor(private heroService: HeroService, private _router: Router) { } - - ngOnInit() { - this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5)); - } - - gotoDetail(hero: Hero) { - let link = ['HeroDetail', { id: hero.id }]; - this._router.navigate(link); - } -} diff --git a/public/docs/_examples/tutorial/ts/app/hero-detail.component.css b/public/docs/_examples/tutorial/ts/app/hero-detail.component.css deleted file mode 100644 index b5ab6e6e0b..0000000000 --- a/public/docs/_examples/tutorial/ts/app/hero-detail.component.css +++ /dev/null @@ -1,29 +0,0 @@ -label { - display: inline-block; - width: 3em; - margin: .5em 0; - color: #607D8B; - font-weight: bold; -} -input { - height: 2em; - font-size: 1em; - padding-left: .4em; -} -button { - margin-top: 20px; - font-family: Arial; - background-color: #eee; - border: none; - padding: 5px 10px; - border-radius: 4px; - cursor: pointer; cursor: hand; -} -button:hover { - background-color: #cfd8dc; -} -button:disabled { - background-color: #eee; - color: #ccc; - cursor: auto; -} diff --git a/public/docs/_examples/tutorial/ts/app/hero-detail.component.html b/public/docs/_examples/tutorial/ts/app/hero-detail.component.html deleted file mode 100644 index af9039dc9f..0000000000 --- a/public/docs/_examples/tutorial/ts/app/hero-detail.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
-

{{hero.name}} details!

-
- {{hero.id}}
-
- - -
- -
\ No newline at end of file diff --git a/public/docs/_examples/tutorial/ts/app/hero-detail.component.ts b/public/docs/_examples/tutorial/ts/app/hero-detail.component.ts deleted file mode 100644 index 0a168944c0..0000000000 --- a/public/docs/_examples/tutorial/ts/app/hero-detail.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component, OnInit } 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', - styleUrls: ['app/hero-detail.component.css'] -}) -export class HeroDetailComponent implements OnInit { - hero: Hero; - - constructor(private heroService: HeroService, - private routeParams: RouteParams) { - } - - ngOnInit() { - let id = +this.routeParams.get('id'); - this.heroService.getHero(id).then(hero => this.hero = hero); - } - - goBack() { - window.history.back(); - } -} diff --git a/public/docs/_examples/tutorial/ts/app/hero.service.ts b/public/docs/_examples/tutorial/ts/app/hero.service.ts deleted file mode 100644 index 7d5c08de07..0000000000 --- a/public/docs/_examples/tutorial/ts/app/hero.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Injectable } from '@angular/core'; - -import { HEROES } from './mock-heroes'; - -@Injectable() -export class HeroService { - getHeroes() { - return Promise.resolve(HEROES); - } - - getHero(id: number) { - return Promise.resolve(HEROES).then( - heroes => heroes.filter(hero => hero.id === id)[0] - ); - } -} diff --git a/public/docs/_examples/tutorial/ts/app/hero.ts b/public/docs/_examples/tutorial/ts/app/hero.ts deleted file mode 100644 index e94ec6124a..0000000000 --- a/public/docs/_examples/tutorial/ts/app/hero.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class Hero { - id: number; - name: string; -} diff --git a/public/docs/_examples/tutorial/ts/app/heroes.component.css b/public/docs/_examples/tutorial/ts/app/heroes.component.css deleted file mode 100644 index 35e45af98d..0000000000 --- a/public/docs/_examples/tutorial/ts/app/heroes.component.css +++ /dev/null @@ -1,59 +0,0 @@ -.selected { - background-color: #CFD8DC !important; - color: white; -} -.heroes { - margin: 0 0 2em 0; - list-style-type: none; - padding: 0; - width: 15em; -} -.heroes li { - cursor: pointer; - position: relative; - left: 0; - background-color: #EEE; - margin: .5em; - padding: .3em 0; - height: 1.6em; - border-radius: 4px; -} -.heroes li:hover { - color: #607D8B; - background-color: #DDD; - left: .1em; -} -.heroes li.selected:hover { - background-color: #BBD8DC !important; - color: white; -} -.heroes .text { - position: relative; - top: -3px; -} -.heroes .badge { - display: inline-block; - font-size: small; - color: white; - padding: 0.8em 0.7em 0 0.7em; - background-color: #607D8B; - line-height: 1em; - position: relative; - left: -1px; - top: -4px; - height: 1.8em; - margin-right: .8em; - border-radius: 4px 0 0 4px; -} -button { - font-family: Arial; - background-color: #eee; - border: none; - padding: 5px 10px; - border-radius: 4px; - cursor: pointer; - cursor: hand; -} -button:hover { - background-color: #cfd8dc; -} diff --git a/public/docs/_examples/tutorial/ts/app/heroes.component.html b/public/docs/_examples/tutorial/ts/app/heroes.component.html deleted file mode 100644 index 6a973bb007..0000000000 --- a/public/docs/_examples/tutorial/ts/app/heroes.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
-

My Heroes

-
    -
  • - {{hero.id}} {{hero.name}} -
  • -
-
-

{{selectedHero.name | uppercase}} is my hero

- -
-
diff --git a/public/docs/_examples/tutorial/ts/app/heroes.component.ts b/public/docs/_examples/tutorial/ts/app/heroes.component.ts deleted file mode 100644 index 1081aab2bd..0000000000 --- a/public/docs/_examples/tutorial/ts/app/heroes.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router-deprecated'; -import { HeroService } from './hero.service'; -import { HeroDetailComponent } from './hero-detail.component'; -import { Hero } from './hero'; - -@Component({ - selector: 'my-heroes', - templateUrl: 'app/heroes.component.html', - styleUrls: ['app/heroes.component.css'], - directives: [HeroDetailComponent] -}) -export class HeroesComponent implements OnInit { - heroes: Hero[]; - selectedHero: Hero; - - constructor(private heroService: HeroService, private router: Router) { } - - getHeroes() { - this.heroService.getHeroes().then(heroes => this.heroes = heroes); - } - - gotoDetail() { - this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]); - } - - ngOnInit() { - this.getHeroes(); - } - - onSelect(hero: Hero) { this.selectedHero = hero; } -} diff --git a/public/docs/_examples/tutorial/ts/app/main.ts b/public/docs/_examples/tutorial/ts/app/main.ts deleted file mode 100644 index 0e07c5e213..0000000000 --- a/public/docs/_examples/tutorial/ts/app/main.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; - -import { HeroService } from './hero.service'; -import { AppComponent } from './app.component'; - -bootstrap(AppComponent, [ - ROUTER_PROVIDERS, - HeroService -]); diff --git a/public/docs/_examples/tutorial/ts/app/mock-heroes.ts b/public/docs/_examples/tutorial/ts/app/mock-heroes.ts deleted file mode 100644 index 406e5eb7f8..0000000000 --- a/public/docs/_examples/tutorial/ts/app/mock-heroes.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Hero } from './hero'; - -export var HEROES: Hero[] = [ - {"id": 11, "name": "Mr. Nice"}, - {"id": 12, "name": "Narco"}, - {"id": 13, "name": "Bombasto"}, - {"id": 14, "name": "Celeritas"}, - {"id": 15, "name": "Magneta"}, - {"id": 16, "name": "RubberMan"}, - {"id": 17, "name": "Dynama"}, - {"id": 18, "name": "Dr IQ"}, - {"id": 19, "name": "Magma"}, - {"id": 20, "name": "Tornado"} -]; diff --git a/public/docs/_examples/tutorial/ts/example-config.json b/public/docs/_examples/tutorial/ts/example-config.json deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/tutorial/ts/index.html b/public/docs/_examples/tutorial/ts/index.html deleted file mode 100644 index ede4eb68e5..0000000000 --- a/public/docs/_examples/tutorial/ts/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Angular 2 Tour of Heroes - - - - - - - - - - - - - - - - - Loading... - - diff --git a/public/docs/_examples/tutorial/ts/plnkr.json b/public/docs/_examples/tutorial/ts/plnkr.json deleted file mode 100644 index fc4ea3e22c..0000000000 --- a/public/docs/_examples/tutorial/ts/plnkr.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": "Tour of Heroes", - "files":[ - "!**/*.d.ts", - "!**/*.js" - ], - "tags": ["tutorial", "tour", "heroes"] -} diff --git a/public/docs/ts/latest/tutorial/index.jade b/public/docs/ts/latest/tutorial/index.jade index 8dfe15f0ea..2845fefcc3 100644 --- a/public/docs/ts/latest/tutorial/index.jade +++ b/public/docs/ts/latest/tutorial/index.jade @@ -27,7 +27,7 @@ include ../_util-fns // #enddocregion intro :marked - [Run the live example](/resources/live-examples/tutorial/ts/plnkr.html) + [Run the live example](/resources/live-examples/toh-6/ts/plnkr.html) // #docregion main .l-main-section From a4bc455030efb83bb23d442f58c6180faa2704c0 Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Thu, 19 May 2016 00:57:35 -0700 Subject: [PATCH 17/41] docs(toh): remove unneeded directive from heroes.component --- public/docs/_examples/toh-5/ts/app/heroes.component.ts | 4 +--- public/docs/_examples/toh-6/ts/app/heroes.component.ts | 4 +--- public/docs/ts/latest/tutorial/toh-pt5.jade | 6 +++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/docs/_examples/toh-5/ts/app/heroes.component.ts b/public/docs/_examples/toh-5/ts/app/heroes.component.ts index 6567c899d9..300f3065e0 100644 --- a/public/docs/_examples/toh-5/ts/app/heroes.component.ts +++ b/public/docs/_examples/toh-5/ts/app/heroes.component.ts @@ -4,7 +4,6 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; import { Hero } from './hero'; -import { HeroDetailComponent } from './hero-detail.component'; import { HeroService } from './hero.service'; // #docregion metadata @@ -13,8 +12,7 @@ import { HeroService } from './hero.service'; selector: 'my-heroes', // #enddocregion heroes-component-renaming templateUrl: 'app/heroes.component.html', - styleUrls: ['app/heroes.component.css'], - directives: [HeroDetailComponent] + styleUrls: ['app/heroes.component.css'] // #docregion heroes-component-renaming }) // #enddocregion heroes-component-renaming diff --git a/public/docs/_examples/toh-6/ts/app/heroes.component.ts b/public/docs/_examples/toh-6/ts/app/heroes.component.ts index 4de48b35fa..8ba9b03e1e 100644 --- a/public/docs/_examples/toh-6/ts/app/heroes.component.ts +++ b/public/docs/_examples/toh-6/ts/app/heroes.component.ts @@ -3,14 +3,12 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router-deprecated'; import { Hero } from './hero'; -import { HeroDetailComponent } from './hero-detail.component'; import { HeroService } from './hero.service'; @Component({ selector: 'my-heroes', templateUrl: 'app/heroes.component.html', - styleUrls: ['app/heroes.component.css'], - directives: [HeroDetailComponent] + styleUrls: ['app/heroes.component.css'] }) export class HeroesComponent implements OnInit { heroes: Hero[]; diff --git a/public/docs/ts/latest/tutorial/toh-pt5.jade b/public/docs/ts/latest/tutorial/toh-pt5.jade index 0afe4be3fc..2a72f68d22 100644 --- a/public/docs/ts/latest/tutorial/toh-pt5.jade +++ b/public/docs/ts/latest/tutorial/toh-pt5.jade @@ -544,7 +544,11 @@ figure.image-display 1. *Cut-and-paste* the styles contents into a new `heroes.component.css` file. 1. *Set* the component metadata's `templateUrl` and `styleUrls` properties to refer to both files. - The revised component data looks like this: + We no longer display the `HeroDetailComponent` in the `HeroesComponent` template because we're navigating to it. + So we can remove it from the metadata `directives` array. The `directives` array is now empty so we delete it. + We might as well delete the `HeroDetailComponent` import statement too. + + The revised component metadata looks like this: +makeExample('toh-5/ts/app/heroes.component.ts', 'metadata', 'app/heroes.component.ts (revised metadata)')(format=".") :marked Now we can see what's going on as we update the component class along the same lines as the dashboard: From 29511831cdbf44f784cb2de6829de1769f00810a Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Tue, 17 May 2016 21:25:41 -0700 Subject: [PATCH 18/41] docs(server-communication): heavily refactored (TS & Dart) --- .../dart/example-config.json | 0 .../dart/lib/app_component.dart | 31 +++ .../dart/lib/hero_data.dart | 4 +- .../dart/lib/toh/hero_list_component.dart | 2 +- .../dart/lib/toh/hero_list_component.html | 1 + .../dart/lib/toh/hero_service.dart | 3 + .../dart/lib/toh/toh_component.dart | 36 --- .../server-communication/dart/pubspec.yaml | 8 +- .../server-communication/dart/web/index.html | 5 +- .../server-communication/dart/web/main.dart | 40 ++- .../server-communication/dart/web/sample.css | 1 + .../server-communication/e2e-spec.js | 87 +++---- .../ts/app/add-rxjs-operators.ts | 9 - .../ts/app/app.component.ts | 37 +++ .../server-communication/ts/app/main.ts | 41 ++-- .../ts/app/rxjs-operators.ts | 16 ++ .../ts/app/toh/hero-list.component.html | 1 + ...nt.1.ts => hero-list.component.promise.ts} | 11 +- .../ts/app/toh/hero-list.component.ts | 7 +- ...o.service.1.ts => hero.service.promise.ts} | 6 +- .../ts/app/toh/hero.service.ts | 6 +- .../server-communication/ts/app/toh/hero.ts | 4 +- .../ts/app/toh/toh.component.ts | 43 ---- .../server-communication/ts/index.html | 6 +- .../server-communication/ts/sample.css | 1 + .../latest/guide/server-communication.jade | 57 +++-- .../ts/latest/guide/server-communication.jade | 229 ++++++++++-------- 27 files changed, 388 insertions(+), 304 deletions(-) create mode 100644 public/docs/_examples/server-communication/dart/example-config.json create mode 100644 public/docs/_examples/server-communication/dart/lib/app_component.dart delete mode 100644 public/docs/_examples/server-communication/dart/lib/toh/toh_component.dart create mode 100644 public/docs/_examples/server-communication/dart/web/sample.css delete mode 100644 public/docs/_examples/server-communication/ts/app/add-rxjs-operators.ts create mode 100644 public/docs/_examples/server-communication/ts/app/app.component.ts create mode 100644 public/docs/_examples/server-communication/ts/app/rxjs-operators.ts rename public/docs/_examples/server-communication/ts/app/toh/{hero-list.component.1.ts => hero-list.component.promise.ts} (79%) rename public/docs/_examples/server-communication/ts/app/toh/{hero.service.1.ts => hero.service.promise.ts} (90%) delete mode 100644 public/docs/_examples/server-communication/ts/app/toh/toh.component.ts create mode 100644 public/docs/_examples/server-communication/ts/sample.css diff --git a/public/docs/_examples/server-communication/dart/example-config.json b/public/docs/_examples/server-communication/dart/example-config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/docs/_examples/server-communication/dart/lib/app_component.dart b/public/docs/_examples/server-communication/dart/lib/app_component.dart new file mode 100644 index 0000000000..55c91e6e4d --- /dev/null +++ b/public/docs/_examples/server-communication/dart/lib/app_component.dart @@ -0,0 +1,31 @@ +// #docplaster +// #docregion +import "package:angular2/core.dart" show Component; + +import "toh/hero_list_component.dart" show HeroListComponent; +import "wiki/wiki_component.dart" show WikiComponent; +import "wiki/wiki_smart_component.dart" show WikiSmartComponent; + +@Component( + selector: "my-app", + template: ''' + + + + ''', + // #enddocregion + /* + // #docregion http-providers + providers: const [ + // in-memory web api provider + const Provider(BrowserClient, + useFactory: HttpClientBackendServiceFactory, deps: const [])], + // #enddocregion http-providers + */ + // #docregion + directives: const [ + HeroListComponent, + WikiComponent, + WikiSmartComponent + ]) +class AppComponent {} diff --git a/public/docs/_examples/server-communication/dart/lib/hero_data.dart b/public/docs/_examples/server-communication/dart/lib/hero_data.dart index 50ec0fab1d..ae0480b98d 100644 --- a/public/docs/_examples/server-communication/dart/lib/hero_data.dart +++ b/public/docs/_examples/server-communication/dart/lib/hero_data.dart @@ -2,7 +2,7 @@ import 'package:http/browser_client.dart'; import 'package:http_in_memory_web_api/http_in_memory_web_api.dart'; -CreateDb createDb = () => { +CreateDb _createDb = () => { 'heroes': [ {"id": "1", "name": "Windstorm"}, {"id": "2", "name": "Bombasto"}, @@ -12,4 +12,4 @@ CreateDb createDb = () => { }; BrowserClient HttpClientBackendServiceFactory() => - new HttpClientInMemoryBackendService(createDb); + new HttpClientInMemoryBackendService(_createDb); diff --git a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart index 58fe0bb40c..23e1d6e9d7 100644 --- a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart +++ b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart @@ -9,7 +9,7 @@ import 'hero_service.dart'; @Component( selector: 'hero-list', templateUrl: 'hero_list_component.html', - styles: const ['.error {color:red;}']) + providers: const [HeroService]) // #docregion component class HeroListComponent implements OnInit { final HeroService _heroService; diff --git a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html index 86e2deedd6..297ffaa6c6 100644 --- a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html +++ b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html @@ -1,4 +1,5 @@ +

Tour of Heroes

Heroes: