diff --git a/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts b/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts new file mode 100644 index 0000000000..d62786fff5 --- /dev/null +++ b/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts @@ -0,0 +1,70 @@ +'use strict'; + +import { browser, element, by } from 'protractor'; +import { logging } from 'selenium-webdriver'; + +describe('Inputs and Outputs', function () { + + + beforeEach(() => { + browser.get(''); + }); + + + // helper function used to test what's logged to the console + async function logChecker(button, contents) { + const logs = await browser + .manage() + .logs() + .get(logging.Type.BROWSER); + const message = logs.filter(({ message }) => + message.indexOf(contents) !== -1 ? true : false + ); + console.log(message); + expect(message.length).toBeGreaterThan(0); + } + + it('should have title Inputs and Outputs', function () { + let title = element.all(by.css('h1')).get(0); + expect(title.getText()).toEqual('Inputs and Outputs'); + }); + + it('should add 123 to the parent list', async () => { + let addToParentButton = element.all(by.css('button')).get(0); + let addToListInput = element.all(by.css('input')).get(0); + let addedItem = element.all(by.css('li')).get(4); + await addToListInput.sendKeys('123'); + await addToParentButton.click(); + expect(addedItem.getText()).toEqual('123'); + }); + + it('should delete item', async () => { + let deleteButton = element.all(by.css('button')).get(1); + const contents = 'Child'; + await deleteButton.click(); + await logChecker(deleteButton, contents); + }); + + it('should log buy the item', async () => { + let buyButton = element.all(by.css('button')).get(2); + const contents = 'Child'; + await buyButton.click(); + await logChecker(buyButton, contents); + }); + + it('should save item for later', async () => { + let saveButton = element.all(by.css('button')).get(3); + const contents = 'Child'; + await saveButton.click(); + await logChecker(saveButton, contents); + }); + + it('should add item to wishlist', async () => { + let addToParentButton = element.all(by.css('button')).get(4); + let addedItem = element.all(by.css('li')).get(6); + await addToParentButton.click(); + expect(addedItem.getText()).toEqual('Television'); + }); + +}); + diff --git a/aio/content/examples/inputs-outputs/example-config.json b/aio/content/examples/inputs-outputs/example-config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.css b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.html b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.html new file mode 100644 index 0000000000..ae7da190a3 --- /dev/null +++ b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.html @@ -0,0 +1,7 @@ +
Save for later item: {{input1}}
+ + + +Item for wishlist: {{input2}}
+ + diff --git a/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts new file mode 100644 index 0000000000..8f93c989bc --- /dev/null +++ b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AliasingComponent } from './aliasing.component'; + +describe('AliasingComponent', () => { + let component: AliasingComponent; + let fixture: ComponentFixtureOpen the console to see the EventEmitter at work when you click Delete.
+ + +Open the console to see the EventEmitter at work when you click Buy.
+ +See aliasing.component.ts for aliases and the console for the EventEmitter console logs.
+ +Latest clearance item: {{clearanceItem}}
+ + diff --git a/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts new file mode 100644 index 0000000000..eaa33528a9 --- /dev/null +++ b/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { InTheMetadataComponent } from './in-the-metadata.component'; + +describe('InTheMetadataComponent', () => { + let component: InTheMetadataComponent; + let fixture: ComponentFixture+ Today's item: {{item}} +
+ + diff --git a/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts new file mode 100644 index 0000000000..7559cb65f6 --- /dev/null +++ b/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ItemDetailComponent } from './item-detail.component'; + +describe('ItemDetailComponent', () => { + let component: ItemDetailComponent; + let fixture: ComponentFixtureitem
, which has
+a type of `string`, however, `@Input()` properties can have any type, such as
+`number`, `string`, `boolean`, or `object`. The value for `item` will come from the parent component, which the next section covers.
-A component's class and template are closely coupled.
-They are both parts of the same thing.
-Together they _are_ the component.
-Exchanges between a component class and its template are internal implementation details.
+Next, in the child component template, add the following:
-### Binding to a different component
-
-You can also bind to a property of a _different_ component.
-In such bindings, the _other_ component's property is to the _left_ of the (`=`).
-
-In the following example, the `AppComponent` template binds `AppComponent` class members to properties of the `HeroDetailComponent` whose selector is `'app-hero-detail'`.
-
-