forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add new getting started guide (angular#27684)
PR Close angular#27684
- Loading branch information
1 parent
004da4b
commit c29112d
Showing
137 changed files
with
2,662 additions
and
671 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
aio/content/examples/getting-started-v0/e2e/src/app.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; // necessary for es6 output in node | ||
|
||
import { browser, element, by } from 'protractor'; | ||
|
||
describe('Getting Started V0', () => { | ||
beforeEach(() => { | ||
return browser.get('/'); | ||
}); | ||
|
||
it('should display "My Store" in the top bar', async() => { | ||
const title = await element(by.css('app-root app-top-bar h1')).getText(); | ||
|
||
expect(title).toEqual('My Store'); | ||
}); | ||
|
||
it('should display "Products" on the homepage', async() => { | ||
const title = await element(by.css('app-root app-product-list h2')).getText(); | ||
|
||
expect(title).toEqual('Products'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"useCommonBoilerplate": false, | ||
"projectType": "getting-started" | ||
} |
3 changes: 3 additions & 0 deletions
3
aio/content/examples/getting-started-v0/src/app/app.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
p { | ||
font-family: Lato; | ||
} |
5 changes: 5 additions & 0 deletions
5
aio/content/examples/getting-started-v0/src/app/app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<app-top-bar></app-top-bar> | ||
|
||
<div class="container"> | ||
<router-outlet></router-outlet> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
aio/content/examples/getting-started-v0/src/app/app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: [ './app.component.css' ] | ||
}) | ||
export class AppComponent {} |
25 changes: 25 additions & 0 deletions
25
aio/content/examples/getting-started-v0/src/app/app.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { RouterModule } from '@angular/router'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { TopBarComponent } from './top-bar/top-bar.component'; | ||
import { ProductListComponent } from './product-list/product-list.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
ReactiveFormsModule, | ||
RouterModule.forRoot([ | ||
{ path: '', component: ProductListComponent }, | ||
]) | ||
], | ||
declarations: [ | ||
AppComponent, | ||
TopBarComponent, | ||
ProductListComponent | ||
], | ||
bootstrap: [ AppComponent ] | ||
}) | ||
export class AppModule { } |
Empty file.
1 change: 1 addition & 0 deletions
1
aio/content/examples/getting-started-v0/src/app/product-list/product-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h2>Products</h2> |
16 changes: 16 additions & 0 deletions
16
aio/content/examples/getting-started-v0/src/app/product-list/product-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { products } from '../products'; | ||
|
||
@Component({ | ||
selector: 'app-product-list', | ||
templateUrl: './product-list.component.html', | ||
styleUrls: ['./product-list.component.css'] | ||
}) | ||
export class ProductListComponent { | ||
products = products; | ||
|
||
share() { | ||
window.alert('The product has been shared!'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
aio/content/examples/getting-started-v0/src/app/products.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const products = [ | ||
{ | ||
name: 'Phone XL', | ||
price: 799, | ||
description: 'A large phone with one of the best screens' | ||
}, | ||
{ | ||
name: 'Phone Mini', | ||
price: 699, | ||
description: 'A great phone with one of the best cameras' | ||
}, | ||
{ | ||
name: 'Phone Standard', | ||
price: 299, | ||
description: '' | ||
} | ||
]; |
Empty file.
5 changes: 5 additions & 0 deletions
5
aio/content/examples/getting-started-v0/src/app/top-bar/top-bar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<a [routerLink]="['/']"> | ||
<h1>My Store</h1> | ||
</a> | ||
|
||
<a [routerLink]="['/cart']" class="button fancy-button"><i class="material-icons">shopping_cart</i>Checkout</a> |
15 changes: 15 additions & 0 deletions
15
aio/content/examples/getting-started-v0/src/app/top-bar/top-bar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-top-bar', | ||
templateUrl: './top-bar.component.html', | ||
styleUrls: ['./top-bar.component.css'] | ||
}) | ||
export class TopBarComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
aio/content/examples/getting-started-v0/src/assets/shipping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"type": "Overnight", | ||
"price": 25.99 | ||
}, | ||
{ | ||
"type": "2-Day", | ||
"price": 9.99 | ||
}, | ||
{ | ||
"type": "Postal", | ||
"price": 2.99 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Angular Getting Started</title> | ||
<base href="/" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
<link | ||
href="https://fonts.googleapis.com/icon?family=Material+Icons" | ||
rel="stylesheet" | ||
/> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { environment } from './environments/environment'; | ||
|
||
import { AppModule } from './app/app.module'; | ||
|
||
if (environment.production) { | ||
enableProdMode(); | ||
} | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"description": "Getting Started", | ||
"files":[ | ||
"!**/*.d.ts", | ||
"!**/*.js", | ||
"!**/*.[0-9].*" | ||
], | ||
"tags": ["Angular", "getting started", "tutorial"] | ||
} |
118 changes: 118 additions & 0 deletions
118
aio/content/examples/getting-started/e2e/src/app.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
'use strict'; // necessary for es6 output in node | ||
|
||
import { browser, element, by, ExpectedConditions as EC, logging, ElementFinder, ElementArrayFinder } from 'protractor'; | ||
|
||
describe('Getting Started', () => { | ||
const pageElements = { | ||
topBarHeader: element(by.css('app-root app-top-bar h1')), | ||
topBarLinks: element(by.css('app-root app-top-bar a')), | ||
topBarCheckoutLink: element(by.cssContainingText('app-root app-top-bar a', 'Checkout')), | ||
productListHeader: element(by.css('app-root app-product-list h2')), | ||
productListItems: element.all(by.css('app-root app-product-list h3')), | ||
productListLinks: element.all(by.css('app-root app-product-list a')), | ||
productDetailsPage: element(by.css('app-root app-product-details div')), | ||
cartPage: element(by.css('app-root app-cart')) | ||
}; | ||
|
||
describe('General', () => { | ||
beforeAll(async() => { | ||
await browser.get('/'); | ||
}); | ||
|
||
it('should display "My Store"', async() => { | ||
const title = await pageElements.topBarHeader.getText(); | ||
|
||
expect(title).toEqual('My Store'); | ||
}); | ||
|
||
it('should display "Products" on the homepage', async() => { | ||
const title = await pageElements.productListHeader.getText(); | ||
|
||
expect(title).toEqual('Products'); | ||
}); | ||
}); | ||
|
||
describe('Product List', () => { | ||
beforeAll(async() => { | ||
await browser.get('/'); | ||
}); | ||
|
||
it('should display 3 items', async() => { | ||
const products = await pageElements.productListItems; | ||
|
||
expect(products.length).toEqual(3); | ||
}); | ||
}); | ||
|
||
describe('Product Details', () => { | ||
beforeEach(async() => { | ||
await browser.get('/'); | ||
}); | ||
|
||
it('should display information for a product', async() => { | ||
await pageElements.productListLinks.get(0).click(); | ||
|
||
const product = pageElements.productDetailsPage; | ||
const productHeader = await product.element(by.css('h3')).getText(); | ||
const productPrice = await product.element(by.css('h4')).getText(); | ||
const productDescription = await product.element(by.css('p')).getText(); | ||
|
||
expect(await product.isDisplayed()).toBeTruthy(); | ||
expect(productHeader).toBe('Phone XL'); | ||
expect(productPrice).toBe('$799.00'); | ||
expect(productDescription).toBe('A large phone with one of the best screens'); | ||
}); | ||
|
||
it('should add the product to the cart', async() => { | ||
await pageElements.productListLinks.get(0).click(); | ||
|
||
const product = pageElements.productDetailsPage; | ||
const buyButton = await product.element(by.css('button')); | ||
const checkoutLink = pageElements.topBarCheckoutLink; | ||
|
||
await buyButton.click(); | ||
await browser.wait(EC.alertIsPresent(), 1000); | ||
await browser.switchTo().alert().accept(); | ||
await checkoutLink.click(); | ||
|
||
const cartItems = await element.all(by.css('app-root app-cart div.cart-item')); | ||
expect(cartItems.length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('Cart', () => { | ||
|
||
beforeEach(async() => { | ||
await browser.get('/'); | ||
}); | ||
|
||
it('should go through the checkout process', async() => { | ||
await pageElements.productListLinks.get(0).click(); | ||
|
||
const checkoutLink = pageElements.topBarCheckoutLink; | ||
const productDetailsPage = pageElements.productDetailsPage; | ||
const buyButton = await productDetailsPage.element(by.css('button')); | ||
|
||
const cartPage = pageElements.cartPage; | ||
const inputFields = cartPage.all(by.css('form input')); | ||
|
||
const purchaseButton = await cartPage.element(by.css('button')); | ||
const nameField = inputFields.get(0); | ||
const addressField = inputFields.get(1); | ||
|
||
await buyButton.click(); | ||
await browser.wait(EC.alertIsPresent(), 1000); | ||
await browser.switchTo().alert().accept(); | ||
await checkoutLink.click(); | ||
|
||
await nameField.sendKeys('Customer'); | ||
await addressField.sendKeys('Address'); | ||
await purchaseButton.click(); | ||
|
||
const logs = await browser.manage().logs().get(logging.Type.BROWSER); | ||
const cartMessages = logs.filter(({ message }) => message.includes('Your order has been submitted')); | ||
|
||
expect(cartMessages.length).toBe(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"useCommonBoilerplate": false, | ||
"projectType": "getting-started" | ||
} |
Empty file.
5 changes: 5 additions & 0 deletions
5
aio/content/examples/getting-started/src/app/app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<app-top-bar></app-top-bar> | ||
|
||
<div class="container"> | ||
<router-outlet></router-outlet> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
aio/content/examples/getting-started/src/app/app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.css'] | ||
}) | ||
export class AppComponent { | ||
} |
Oops, something went wrong.