chore(playground): clang-format

This commit is contained in:
Jason Choi
2016-08-05 12:26:28 -07:00
committed by Alex Rickabaugh
parent 0d1f3c3b07
commit 6baf3baedd
60 changed files with 3339 additions and 3375 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ const os = require('os');
const srcsToFmt =
['tools/**/*.ts', 'modules/@angular/**/*.ts', '!tools/public_api_guard/**/*.d.ts',
'modules/benchpress/**/*.ts'];
'modules/benchpress/**/*.ts', 'modules/playground/**/*.ts'];
gulp.task('format:enforce', () => {
const format = require('gulp-clang-format');
@@ -43,9 +43,9 @@ describe('hash routing example app', function() {
element(by.css('#goodbye-link-blank')).click();
expect(browser.driver.getCurrentUrl()).not.toContain('#/bye');
browser.getAllWindowHandles().then(function(windows) {
browser.switchTo()
.window(windows[1])
.then(function() { expect(browser.driver.getCurrentUrl()).toContain("#/bye"); });
browser.switchTo().window(windows[1]).then(function() {
expect(browser.driver.getCurrentUrl()).toContain('#/bye');
});
});
});
});
@@ -32,11 +32,14 @@ describe('hello world', function() {
});
function getComponentText(selector: any /** TODO #9100 */, innerSelector: any /** TODO #9100 */) {
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
innerSelector + '").textContent');
return browser.executeScript(
'return document.querySelector("' + selector + '").querySelector("' + innerSelector +
'").textContent');
}
function clickComponentButton(selector: any /** TODO #9100 */, innerSelector: any /** TODO #9100 */) {
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
innerSelector + '").click()');
function clickComponentButton(
selector: any /** TODO #9100 */, innerSelector: any /** TODO #9100 */) {
return browser.executeScript(
'return document.querySelector("' + selector + '").querySelector("' + innerSelector +
'").click()');
}
@@ -23,6 +23,7 @@ describe('http', function() {
});
function getComponentText(selector: any /** TODO #9100 */, innerSelector: any /** TODO #9100 */) {
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
innerSelector + '").textContent.trim()');
return browser.executeScript(
'return document.querySelector("' + selector + '").querySelector("' + innerSelector +
'").textContent.trim()');
}
@@ -23,6 +23,7 @@ describe('jsonp', function() {
});
function getComponentText(selector: any /** TODO #9100 */, innerSelector: any /** TODO #9100 */) {
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
innerSelector + '").textContent.trim()');
return browser.executeScript(
'return document.querySelector("' + selector + '").querySelector("' + innerSelector +
'").textContent.trim()');
}
@@ -70,8 +70,8 @@ describe('deprecated routing inbox-app', () => {
waitForElement('#item-10');
element(by.css('#item-10')).click();
waitForElement('#record-id');
var recordId = element(by.css("#record-id"));
browser.wait(protractor.until.elementTextIs(recordId, "ID: 10"), 5000);
var recordId = element(by.css('#record-id'));
browser.wait(protractor.until.elementTextIs(recordId, 'ID: 10'), 5000);
expect(recordId.getText()).toEqual('ID: 10');
});
@@ -93,7 +93,7 @@ describe('deprecated routing inbox-app', () => {
element(by.css('.sort-button')).click();
expect(browser.getCurrentUrl()).toMatch(/\/#\?sort=date$/);
waitForElement('.inbox-item-record');
expect(element(by.css(".inbox-item-record > a")).getAttribute("id")).toEqual("item-137");
expect(element(by.css('.inbox-item-record > a')).getAttribute('id')).toEqual('item-137');
});
})
});
@@ -38,19 +38,19 @@ describe('sourcemaps', function() {
const content =
fs.readFileSync('dist/all/playground/src/sourcemap/index.js').toString("utf8");
const marker = "//# sourceMappingURL=data:application/json;base64,";
fs.readFileSync('dist/all/playground/src/sourcemap/index.js').toString('utf8');
const marker = '//# sourceMappingURL=data:application/json;base64,';
const index = content.indexOf(marker);
const sourceMapData =
new Buffer(content.substring(index + marker.length), 'base64').toString("utf8");
new Buffer(content.substring(index + marker.length), 'base64').toString('utf8');
var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
var originalPosition = decoder.originalPositionFor({line: errorLine, column: errorColumn});
var sourceCodeLines =
fs.readFileSync('modules/playground/src/sourcemap/index.ts', {encoding: 'UTF-8'})
.split('\n');
var sourceCodeLines = fs.readFileSync('modules/playground/src/sourcemap/index.ts', {
encoding: 'UTF-8'
}).split('\n');
expect(sourceCodeLines[originalPosition.line - 1])
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
});
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from "e2e_util/e2e_util";
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
// TODO(i): reenable once we are using a version of protractor containing the
// change in https://github.com/angular/protractor/pull/3403
@@ -56,16 +56,17 @@ describe('WebWorkers Input', function() {
});
function waitForBootstrap() {
browser
.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
.then(_ => {
let elem = element(by.css(selector + ' h2'));
browser.wait(protractor.until.elementTextIs(elem, 'Input App'), 5000);
}, _ => {
// jasmine will timeout if this gets called too many times
console.log('>> unexpected timeout -> browser.refresh()');
browser.refresh();
waitForBootstrap();
});
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
.then(
_ => {
let elem = element(by.css(selector + ' h2'));
browser.wait(protractor.until.elementTextIs(elem, 'Input App'), 5000);
},
_ => {
// jasmine will timeout if this gets called too many times
console.log('>> unexpected timeout -> browser.refresh()');
browser.refresh();
waitForBootstrap();
});
}
});
@@ -13,7 +13,7 @@ describe('WebWorkers Kitchen Sink', function() {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
var selector = "hello-app .greeting";
var selector = 'hello-app .greeting';
var URL = 'all/playground/src/web_workers/kitchen_sink/index.html';
it('should greet', () => {
@@ -24,7 +24,7 @@ describe('WebWorkers Kitchen Sink', function() {
browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
var elem = element(by.css(selector));
browser.wait(protractor.until.elementTextIs(elem, 'hello world!'), 5000);
expect(elem.getText()).toEqual("hello world!");
expect(elem.getText()).toEqual('hello world!');
});
@@ -37,21 +37,21 @@ describe('WebWorkers Kitchen Sink', function() {
browser.wait(protractor.until.elementLocated(by.css(changeButtonSelector)), 15000);
element(by.css(changeButtonSelector)).click();
var elem = element(by.css(selector));
browser.wait(protractor.until.elementTextIs(elem, "howdy world!"), 5000);
expect(elem.getText()).toEqual("howdy world!");
browser.wait(protractor.until.elementTextIs(elem, 'howdy world!'), 5000);
expect(elem.getText()).toEqual('howdy world!');
});
it("should display correct key names", () => {
it('should display correct key names', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
browser.wait(protractor.until.elementLocated(by.css(".sample-area")), 15000);
browser.wait(protractor.until.elementLocated(by.css('.sample-area')), 15000);
var area = element.all(by.css(".sample-area")).first();
var area = element.all(by.css('.sample-area')).first();
expect(area.getText()).toEqual('(none)');
area.sendKeys('u');
browser.wait(protractor.until.elementTextIs(area, "U"), 5000);
expect(area.getText()).toEqual("U");
browser.wait(protractor.until.elementTextIs(area, 'U'), 5000);
expect(area.getText()).toEqual('U');
});
});
@@ -10,37 +10,37 @@ import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
var URL = 'all/playground/src/web_workers/message_broker/index.html';
describe("MessageBroker", function() {
describe('MessageBroker', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
it("should bootstrap", () => {
it('should bootstrap', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
expect(element(by.css("app h1")).getText()).toEqual("WebWorker MessageBroker Test");
expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test');
});
it("should echo messages", () => {
const VALUE = "Hi There";
it('should echo messages', () => {
const VALUE = 'Hi There';
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
var input = element.all(by.css("#echo_input")).first();
var input = element.all(by.css('#echo_input')).first();
input.sendKeys(VALUE);
element(by.css("#send_echo")).click();
var area = element(by.css("#echo_result"));
element(by.css('#send_echo')).click();
var area = element(by.css('#echo_result'));
browser.wait(protractor.until.elementTextIs(area, VALUE), 5000);
expect(area.getText()).toEqual(VALUE);
});
});
function waitForBootstrap(): void {
browser.wait(protractor.until.elementLocated(by.css("app h1")), 15000);
browser.wait(protractor.until.elementLocated(by.css('app h1')), 15000);
}
@@ -8,7 +8,7 @@
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
describe("WebWorker Router", () => {
describe('WebWorker Router', () => {
beforeEach(() => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
@@ -20,43 +20,43 @@ describe("WebWorker Router", () => {
browser.ignoreSynchronization = false;
});
let contentSelector = "app main h1";
let navSelector = "app nav ul";
let contentSelector = 'app main h1';
let navSelector = 'app nav ul';
var baseUrl = 'all/playground/src/web_workers/router/index.html';
it("should route on click", () => {
it('should route on click', () => {
browser.get(baseUrl);
waitForElement(contentSelector);
var content = element(by.css(contentSelector));
expect(content.getText()).toEqual("Start");
expect(content.getText()).toEqual('Start');
let aboutBtn = element(by.css(navSelector + " .about"));
let aboutBtn = element(by.css(navSelector + ' .about'));
aboutBtn.click();
waitForUrl(/\/about/);
waitForElement(contentSelector);
waitForElementText(contentSelector, "About");
waitForElementText(contentSelector, 'About');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual("About");
expect(content.getText()).toEqual('About');
expect(browser.getCurrentUrl()).toMatch(/\/about/);
let contactBtn = element(by.css(navSelector + " .contact"));
let contactBtn = element(by.css(navSelector + ' .contact'));
contactBtn.click();
waitForUrl(/\/contact/);
waitForElement(contentSelector);
waitForElementText(contentSelector, "Contact");
waitForElementText(contentSelector, 'Contact');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual("Contact");
expect(content.getText()).toEqual('Contact');
expect(browser.getCurrentUrl()).toMatch(/\/contact/);
});
it("should load the correct route from the URL", () => {
browser.get(baseUrl + "#/about");
it('should load the correct route from the URL', () => {
browser.get(baseUrl + '#/about');
waitForElement(contentSelector);
waitForElementText(contentSelector, "About");
waitForElementText(contentSelector, 'About');
let content = element(by.css(contentSelector));
expect(content.getText()).toEqual("About");
expect(content.getText()).toEqual('About');
});
function waitForElement(selector: string): void {
@@ -22,11 +22,11 @@ describe('WebWorkers Todo', function() {
browser.get(URL);
waitForBootstrap();
expect(element(by.css("#todoapp header")).getText()).toEqual("todos");
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
});
});
function waitForBootstrap(): void {
browser.wait(protractor.until.elementLocated(by.css("todo-app #todoapp")), 15000);
browser.wait(protractor.until.elementLocated(by.css('todo-app #todoapp')), 15000);
}
@@ -6,21 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import {
Component,
trigger,
state,
transition,
keyframes,
group,
animate,
style,
sequence
} from '@angular/core';
import {Component, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
@Component({
host: {
'[@backgroundAnimation]': "bgStatus"
'[@backgroundAnimation]': 'bgStatus'
},
selector: 'animate-app',
styleUrls: ['css/animate-app.css'],
@@ -39,31 +29,31 @@ import {
</div>
`,
animations: [
trigger("backgroundAnimation", [
state("focus", style({ "background-color":"white" })),
state("blur", style({ "background-color":"grey" })),
transition("* => *", [
trigger('backgroundAnimation', [
state('focus', style({ 'background-color':'white' })),
state('blur', style({ 'background-color':'grey' })),
transition('* => *', [
animate(500)
])
]),
trigger("boxAnimation", [
state("*", style({ "height": "*", "background-color": "#dddddd", "color":"black" })),
state("void, hidden", style({ "height": 0, "opacity": 0 })),
state("start", style({ "background-color": "red", "height": "*" })),
state("active", style({ "background-color": "orange", "color": "white", "font-size":"100px" })),
trigger('boxAnimation', [
state('*', style({ 'height': '*', 'background-color': '#dddddd', 'color':'black' })),
state('void, hidden', style({ 'height': 0, 'opacity': 0 })),
state('start', style({ 'background-color': 'red', 'height': '*' })),
state('active', style({ 'background-color': 'orange', 'color': 'white', 'font-size':'100px' })),
transition("active <=> start", [
animate(500, style({ "transform": "scale(2)" })),
transition('active <=> start', [
animate(500, style({ 'transform': 'scale(2)' })),
animate(500)
]),
transition("* => *", [
animate(1000, style({ "opacity": 1, "height": 300 })),
animate(1000, style({ "background-color": "blue" })),
transition('* => *', [
animate(1000, style({ 'opacity': 1, 'height': 300 })),
animate(1000, style({ 'background-color': 'blue' })),
animate(1000, keyframes([
style({ "background-color": "blue", "color": "black", "offset": 0.2 }),
style({ "background-color": "brown", "color": "black", "offset": 0.5 }),
style({ "background-color": "black", "color": "white", "offset": 1 })
style({ 'background-color': 'blue', 'color': 'black', 'offset': 0.2 }),
style({ 'background-color': 'brown', 'color': 'black', 'offset': 0.5 }),
style({ 'background-color': 'black', 'color': 'white', 'offset': 1 })
])),
animate(2000)
])
@@ -84,7 +74,7 @@ export class AnimateApp {
}
reorderAndRemove() {
this.items = this.items.sort((a: any,b: any) => Math.random() - 0.5);
this.items = this.items.sort((a: any, b: any) => Math.random() - 0.5);
this.items.splice(Math.floor(Math.random() * this.items.length), 1);
this.items.splice(Math.floor(Math.random() * this.items.length), 1);
this.items[Math.floor(Math.random() * this.items.length)] = 99;
@@ -96,12 +86,7 @@ export class AnimateApp {
if (s == 'void') {
this.items = [];
} else {
this.items = [
1,2,3,4,5,
6,7,8,9,10,
11,12,13,14,15,
16,17,18,19,20
];
this.items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
}
}
}
+2 -1
View File
@@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AnimateApp} from './app/animate-app';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {AnimateApp} from './app/animate-app';
export function main() {
bootstrap(AnimateApp);
}
+2 -2
View File
@@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
import {NgIf} from '@angular/common';
import {Component} from '@angular/core';
import {TimerWrapper} from '@angular/core/src/facade/async';
import {bootstrap} from '@angular/platform-browser-dynamic';
@Component({
selector: 'async-app',
+11 -6
View File
@@ -29,11 +29,14 @@ declare var System: any;
'@angular/core': '/packages-dist/core/bundles/core.umd.js',
'@angular/common': '/packages-dist/common/bundles/common.umd.js',
'@angular/compiler': '/packages-dist/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': '/packages-dist/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': '/packages-dist/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/platform-browser':
'/packages-dist/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic':
'/packages-dist/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': '/packages-dist/http/bundles/http.umd.js',
'@angular/upgrade': '/packages-dist/upgrade/bundles/upgrade.umd.js',
'@angular/router-deprecated': '/packages-dist/router-deprecated/bundles/router-deprecated.umd.js',
'@angular/router-deprecated':
'/packages-dist/router-deprecated/bundles/router-deprecated.umd.js',
'@angular/router': '/packages-dist/router/bundles/router.umd.js',
'@angular/core/src/facade': '/all/@angular/core/src/facade',
'rxjs': location.pathname.replace(/\w+\.html$/i, '') + 'rxjs'
@@ -45,12 +48,12 @@ declare var System: any;
});
} else {
console.warn(
"Not using the Angular bundles. Don't use this configuration for e2e/performance tests!");
'Not using the Angular bundles. Don\'t use this configuration for e2e/performance tests!');
System.config({
map: {'index': 'index.js', '@angular': '/all/@angular'},
packages: {
'app': { defaultExtension: 'js' },
'app': {defaultExtension: 'js'},
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
@@ -66,7 +69,9 @@ declare var System: any;
// BOOTSTRAP the app!
System.import('index').then(function(m: any /** TODO #9100 */) { m.main(); }, console.error.bind(console));
System.import('index').then(function(m: any /** TODO #9100 */) {
m.main();
}, console.error.bind(console));
}
+4 -2
View File
@@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
@Component({selector: 'gestures-app', templateUrl: 'template.html'})
class GesturesCmp {
@@ -15,7 +15,9 @@ class GesturesCmp {
pinchScale: number = 1;
rotateAngle: number = 0;
onSwipe(event: any /** TODO #9100 */): void { this.swipeDirection = event.deltaX > 0 ? 'right' : 'left'; }
onSwipe(event: any /** TODO #9100 */): void {
this.swipeDirection = event.deltaX > 0 ? 'right' : 'left';
}
onPinch(event: any /** TODO #9100 */): void { this.pinchScale = event.scale; }
+4 -4
View File
@@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {RouteConfig, Route, ROUTER_PROVIDERS, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Route, RouteConfig} from '@angular/router-deprecated';
@Component({selector: 'hello-cmp', template: `hello`})
@@ -46,6 +46,6 @@ class AppCmp {
export function main() {
bootstrap(AppCmp,
[ROUTER_PROVIDERS, {provide: LocationStrategy, useClass: HashLocationStrategy}]);
bootstrap(
AppCmp, [ROUTER_PROVIDERS, {provide: LocationStrategy, useClass: HashLocationStrategy}]);
}
+1 -1
View File
@@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, ElementRef, Injectable, Renderer} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Renderer, ElementRef, Component, Directive, Injectable} from '@angular/core';
export function main() {
// Bootstrapping only requires specifying a root component.
+2 -1
View File
@@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import 'rxjs/add/operator/map';
import {Component} from '@angular/core';
import {Http, Response} from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
selector: 'http-app',
+2 -1
View File
@@ -6,8 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {HTTP_PROVIDERS} from '@angular/http';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {HttpCmp} from './app/http_comp';
export function main() {
+2 -1
View File
@@ -6,8 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {JSONP_PROVIDERS} from '@angular/http';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {JsonpCmp} from './app/jsonp_comp';
export function main() {
+2 -2
View File
@@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
// TODO: remove deep import by reimplementing the event name serialization
import {KeyEventsPlugin} from "@angular/platform-browser/src/dom/events/key_events";
import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_events';
@Component({
selector: 'key-events-app',
@@ -6,20 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {
FORM_DIRECTIVES,
ControlGroup,
Validators,
NgFormModel,
FormBuilder,
NgIf,
NgFor
} from '@angular/common';
import {Component, Directive, Host} from '@angular/core';
import {print, isPresent} from '@angular/core/src/facade/lang';
import {ControlGroup, FORM_DIRECTIVES, FormBuilder, NgFor, NgFormModel, NgIf, Validators} from '@angular/common';
import {AbstractControl} from '@angular/common';
import {Component, Directive, Host} from '@angular/core';
import {isPresent, print} from '@angular/core/src/facade/lang';
import {bootstrap} from '@angular/platform-browser-dynamic';
/**
* Custom validator.
@@ -28,7 +20,7 @@ function creditCardValidator(c: AbstractControl): {[key: string]: boolean} {
if (isPresent(c.value) && /^\d{16}$/.test(c.value)) {
return null;
} else {
return {"invalidCreditCard": true};
return {'invalidCreditCard': true};
}
}
@@ -148,19 +140,19 @@ class ModelDrivenForms {
constructor(fb: FormBuilder) {
this.form = fb.group({
"firstName": ["", Validators.required],
"middleName": [""],
"lastName": ["", Validators.required],
"country": ["Canada", Validators.required],
"creditCard": ["", Validators.compose([Validators.required, creditCardValidator])],
"amount": [0, Validators.required],
"email": ["", Validators.required],
"comments": [""]
'firstName': ['', Validators.required],
'middleName': [''],
'lastName': ['', Validators.required],
'country': ['Canada', Validators.required],
'creditCard': ['', Validators.compose([Validators.required, creditCardValidator])],
'amount': [0, Validators.required],
'email': ['', Validators.required],
'comments': ['']
});
}
onSubmit(): void {
print("Submitting:");
print('Submitting:');
print(this.form.value);
}
}
@@ -6,17 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {
Component,
EventEmitter,
Injectable,
Input,
Output
} from '@angular/core';
import {NgIf, NgFor, FORM_DIRECTIVES} from '@angular/common';
import {FORM_DIRECTIVES, NgFor, NgIf} from '@angular/common';
import {Component, EventEmitter, Injectable, Input, Output} from '@angular/core';
import {ListWrapper} from '@angular/core/src/facade/collection';
import {bootstrap} from '@angular/platform-browser-dynamic';
/**
* You can find the Angular 1 implementation of this example here:
@@ -26,15 +19,17 @@ import {ListWrapper} from '@angular/core/src/facade/collection';
// ---- model
class OrderItem {
constructor(public orderItemId: number, public orderId: number, public productName: string,
public qty: number, public unitPrice: number) {}
constructor(
public orderItemId: number, public orderId: number, public productName: string,
public qty: number, public unitPrice: number) {}
get total(): number { return this.qty * this.unitPrice; }
}
class Order {
constructor(public orderId: number, public customerName: string, public limit: number,
private _dataService: DataService) {}
constructor(
public orderId: number, public customerName: string, public limit: number,
private _dataService: DataService) {}
get items(): OrderItem[] { return this._dataService.itemsFor(this); }
get total(): number { return this.items.map(i => i.total).reduce((a, b) => a + b, 0); }
@@ -53,17 +48,16 @@ class DataService {
constructor() {
this.orders = [
new Order(_nextId++, "J. Coltrane", 100, this),
new Order(_nextId++, "B. Evans", 200, this)
new Order(_nextId++, 'J. Coltrane', 100, this), new Order(_nextId++, 'B. Evans', 200, this)
];
this.orderItems = [
new OrderItem(_nextId++, this.orders[0].orderId, "Bread", 5, 1),
new OrderItem(_nextId++, this.orders[0].orderId, "Brie", 5, 2),
new OrderItem(_nextId++, this.orders[0].orderId, "IPA", 5, 3),
new OrderItem(_nextId++, this.orders[0].orderId, 'Bread', 5, 1),
new OrderItem(_nextId++, this.orders[0].orderId, 'Brie', 5, 2),
new OrderItem(_nextId++, this.orders[0].orderId, 'IPA', 5, 3),
new OrderItem(_nextId++, this.orders[1].orderId, "Mozzarella", 5, 2),
new OrderItem(_nextId++, this.orders[1].orderId, "Wine", 5, 3)
new OrderItem(_nextId++, this.orders[1].orderId, 'Mozzarella', 5, 2),
new OrderItem(_nextId++, this.orders[1].orderId, 'Wine', 5, 3)
];
}
@@ -72,7 +66,7 @@ class DataService {
}
addItemForOrder(order: Order): void {
this.orderItems.push(new OrderItem(_nextId++, order.orderId, "", 0, 0));
this.orderItems.push(new OrderItem(_nextId++, order.orderId, '', 0, 0));
}
deleteItem(item: OrderItem): void { ListWrapper.remove(this.orderItems, item); }
@@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {FORM_DIRECTIVES, NgFor, NgIf} from '@angular/common';
import {Component, Injectable} from '@angular/core';
import {NgIf, NgFor, FORM_DIRECTIVES} from '@angular/common';
import {bootstrap} from '@angular/platform-browser-dynamic';
/**
* You can find the Angular 1 implementation of this example here:
@@ -50,16 +50,11 @@ class DataService {
constructor() {
this.persons = [
new Person('Victor', 'Savkin', 1930),
new Person('Igor', 'Minar', 1920),
new Person('John', 'Papa', 1910),
new Person('Nancy', 'Duarte', 1910),
new Person('Jack', 'Papa', 1910),
new Person('Jill', 'Papa', 1910),
new Person('Ward', 'Bell', 1910),
new Person('Robert', 'Bell', 1910),
new Person('Tracy', 'Ward', 1910),
new Person('Dan', 'Wahlin', 1910)
new Person('Victor', 'Savkin', 1930), new Person('Igor', 'Minar', 1920),
new Person('John', 'Papa', 1910), new Person('Nancy', 'Duarte', 1910),
new Person('Jack', 'Papa', 1910), new Person('Jill', 'Papa', 1910),
new Person('Ward', 'Bell', 1910), new Person('Robert', 'Bell', 1910),
new Person('Tracy', 'Ward', 1910), new Person('Dan', 'Wahlin', 1910)
];
this.persons[0].friends = [0, 1, 2, 6, 9].map(_ => this.persons[_]);
@@ -6,8 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {MyCmp} from './app/my_cmp';
export function main() {
File diff suppressed because it is too large Load Diff
+20 -22
View File
@@ -6,12 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Injectable} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import * as db from './data';
import {Location} from '@angular/common';
import {PromiseWrapper, PromiseCompleter} from '@angular/core/src/facade/async';
import {isPresent, DateWrapper} from '@angular/core/src/facade/lang';
import {Component, Injectable} from '@angular/core';
import {PromiseCompleter, PromiseWrapper} from '@angular/core/src/facade/async';
import {DateWrapper, isPresent} from '@angular/core/src/facade/lang';
import {ActivatedRoute, Router} from '@angular/router';
import * as db from './data';
export class InboxRecord {
id: string = '';
@@ -72,8 +73,8 @@ export class DbService {
}
emails(): Promise<any[]> {
return this.getData().then((data: any[]): any[] =>
data.filter(record => !isPresent(record['draft'])));
return this.getData().then(
(data: any[]): any[] => data.filter(record => !isPresent(record['draft'])));
}
email(id: any /** TODO #9100 */): Promise<any> {
@@ -97,18 +98,19 @@ export class InboxCmp {
constructor(public router: Router, db: DbService, route: ActivatedRoute) {
route.params.forEach(p => {
const sortType = p['sort'];
const sortEmailsByDate = isPresent(sortType) && sortType == "date";
const sortEmailsByDate = isPresent(sortType) && sortType == 'date';
PromiseWrapper.then(db.emails(), (emails: any[]) => {
this.ready = true;
this.items = emails.map(data => new InboxRecord(data));
if (sortEmailsByDate) {
this.items.sort((a: InboxRecord, b: InboxRecord) =>
DateWrapper.toMillis(DateWrapper.fromISOString(a.date)) <
DateWrapper.toMillis(DateWrapper.fromISOString(b.date)) ?
-1 :
1);
this.items.sort(
(a: InboxRecord, b: InboxRecord) =>
DateWrapper.toMillis(DateWrapper.fromISOString(a.date)) <
DateWrapper.toMillis(DateWrapper.fromISOString(b.date)) ?
-1 :
1);
}
});
});
@@ -130,14 +132,10 @@ export class DraftsCmp {
}
export const ROUTER_CONFIG = [
{path: '', terminal: true, redirectTo: 'inbox'},
{path: 'inbox', component: InboxCmp},
{path: 'drafts', component: DraftsCmp},
{path: 'detail', loadChildren: 'app/inbox-detail.js' }
{path: '', terminal: true, redirectTo: 'inbox'}, {path: 'inbox', component: InboxCmp},
{path: 'drafts', component: DraftsCmp}, {path: 'detail', loadChildren: 'app/inbox-detail.js'}
];
@Component({
selector: 'inbox-app',
templateUrl: 'app/inbox-app.html'
})
export class InboxApp {}
@Component({selector: 'inbox-app', templateUrl: 'app/inbox-app.html'})
export class InboxApp {
}

Some files were not shown because too many files have changed in this diff Show More