Skip to content

docs(aio): update ToH for CLI #19811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions aio/content/examples/toh-pt0/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'; // necessary for es6 output in node

import { browser, element, by } from 'protractor';

describe('Tour of Heroes', () => {
beforeEach(() => {
return browser.get('/');
});

it('should display "Tour of Heroes"', () => {
let title = element(by.css('app-root h1')).getText();
expect(title).toEqual('Tour of Heroes');
});
});
Empty file.
10 changes: 10 additions & 0 deletions aio/content/examples/toh-pt0/plnkr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"description": "Tour of Heroes: Part 0",
"basePath": "src/",
"files":[
"!**/*.d.ts",
"!**/*.js",
"!**/*.[1].*"
],
"tags": ["tutorial", "tour", "heroes"]
}
Empty file.
1 change: 1 addition & 0 deletions aio/content/examples/toh-pt0/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>{{title}}</h1>
32 changes: 32 additions & 0 deletions aio/content/examples/toh-pt0/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { TestBed, async } from '@angular/core/testing';

import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));

it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));

it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));

it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
12 changes: 12 additions & 0 deletions aio/content/examples/toh-pt0/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
// #docregion set-title
title = 'Tour of Heroes';
// #enddocregion set-title
}
16 changes: 16 additions & 0 deletions aio/content/examples/toh-pt0/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
14 changes: 14 additions & 0 deletions aio/content/examples/toh-pt0/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tour of Heroes</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Master Styles */
/* Application-wide Styles */
h1 {
color: #369;
font-family: Arial, Helvetica, sans-serif;
Expand Down
44 changes: 0 additions & 44 deletions aio/content/examples/toh-pt1/app/app.component.1.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { browser, element, by, ElementFinder } from 'protractor';
import { promise } from 'selenium-webdriver';

const expectedH1 = 'Tour of Heroes';
const expectedTitle = `Angular ${expectedH1}`;
const expectedTitle = `${expectedH1}`;

class Hero {
id: number;
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Tutorial part 1', () => {
let page = getPageElts();
let hero = await Hero.fromDetail(page.heroDetail);
expect(hero.id).toEqual(expectedHero.id);
expect(hero.name).toEqual(expectedHero.name);
expect(hero.name).toEqual(expectedHero.name.toUpperCase());
});

it(`shows updated hero name`, async () => {
Expand All @@ -58,13 +58,13 @@ describe('Tutorial part 1', () => {
let hero = await Hero.fromDetail(page.heroDetail);
let newName = expectedHero.name + nameSuffix;
expect(hero.id).toEqual(expectedHero.id);
expect(hero.name).toEqual(newName);
expect(hero.name).toEqual(newName.toUpperCase());
});

});

function getPageElts() {
return {
heroDetail: element(by.css('my-app'))
heroDetail: element(by.css('app-root'))
};
}
3 changes: 2 additions & 1 deletion aio/content/examples/toh-pt1/plnkr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"files":[
"!**/*.d.ts",
"!**/*.js",
"!**/*.[1].*"
"!**/*.[1].*",
"!**/dummy.module.ts"
],
"tags": ["tutorial", "tour", "heroes"]
}
Empty file.
2 changes: 2 additions & 0 deletions aio/content/examples/toh-pt1/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>{{title}}</h1>
<app-heroes></app-heroes>
29 changes: 3 additions & 26 deletions aio/content/examples/toh-pt1/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
// #docregion
import { Component } from '@angular/core';

// #docregion hero-class-1
export class Hero {
id: number;
name: string;
}
// #enddocregion hero-class-1

@Component({
selector: 'my-app',
// #docregion editing-Hero
template: `
<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
`
// #enddocregion editing-Hero
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Tour of Heroes';
// #docregion hero-property-1
hero: Hero = {
id: 1,
name: 'Windstorm'
};
// #enddocregion hero-property-1
}
28 changes: 20 additions & 8 deletions aio/content/examples/toh-pt1/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
// #docplaster
// #docregion
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; // <-- NgModel lives here
import { NgModule } from '@angular/core';
// #docregion formsmodule-js-import
import { FormsModule } from '@angular/forms'; // <-- NgModel lives here
// #enddocregion formsmodule-js-import

import { AppComponent } from './app.component';
import { AppComponent } from './app.component';
// #docregion heroes-import
import { HeroesComponent } from './heroes/heroes.component';
// #enddocregion heroes-import

@NgModule({
// #docregion declarations
declarations: [
AppComponent,
HeroesComponent
],
// #enddocregion declarations
// #docregion ng-imports
imports: [
BrowserModule,
FormsModule // <-- import the FormsModule before binding with [(ngModel)]
],
declarations: [
AppComponent
FormsModule
],
bootstrap: [ AppComponent ]
// #enddocregion ng-imports
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
4 changes: 4 additions & 0 deletions aio/content/examples/toh-pt1/src/app/hero.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export class Hero {
id: number;
name: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- #docregion show-hero-1 -->
{{hero}}
<!-- #enddocregion show-hero-1 -->

<!-- #docregion show-hero-2 -->
<h2>{{ hero.name }} Details</h2>
<div><span>id: </span>{{hero.id}}</div>
<div><span>name: </span>{{hero.name}}</div>
<!-- #enddocregion show-hero-2 -->

<!-- #docregion name-input -->
<div>
<label>name:
<input [(ngModel)]="hero.name" placeholder="name">
</label>
</div>
<!-- #enddocregion name-input -->
Empty file.
10 changes: 10 additions & 0 deletions aio/content/examples/toh-pt1/src/app/heroes/heroes.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- #docregion -->
<!-- #docregion pipe -->
<h2>{{ hero.name | uppercase }} Details</h2>
<!-- #enddocregion pipe -->
<div><span>id: </span>{{hero.id}}</div>
<div>
<label>name:
<input [(ngModel)]="hero.name" placeholder="name">
</label>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { HeroesComponent } from './heroes.component';

describe('HeroesComponent', () => {
let component: HeroesComponent;
let fixture: ComponentFixture<HeroesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeroesComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(HeroesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
35 changes: 35 additions & 0 deletions aio/content/examples/toh-pt1/src/app/heroes/heroes.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// #docplaster
// #docregion, v1
import { Component, OnInit } from '@angular/core';
// #enddocregion v1
import { Hero } from '../hero';
// #docregion v1

@Component({
selector: 'app-heroes',
templateUrl: './heroes.component.html',
styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {
// #enddocregion, v1
/*
// #docregion add-hero
hero = 'Windstorm';
// #enddocregion add-hero
*/
// #docregion
// #docregion hero-property-1
hero: Hero = {
id: 1,
name: 'Windstorm'
};
// #enddocregion hero-property-1
// #docregion v1

constructor() { }

ngOnInit() {
}

}
// #enddocregion, v1
Loading