@ -11,7 +11,6 @@ import {browser} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('hello world', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('hello world app', function() {
|
||||
@ -30,7 +29,6 @@ describe('hello world', function() {
|
||||
expect(getComponentText('hello-app', '.greeting')).toEqual('howdy world!');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function getComponentText(selector: string, innerSelector: string) {
|
||||
|
@ -11,7 +11,6 @@ import {browser} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('http', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('fetching', function() {
|
||||
@ -25,6 +24,6 @@ describe('http', function() {
|
||||
});
|
||||
|
||||
function getComponentText(selector: string, innerSelector: string) {
|
||||
return browser.executeScript(
|
||||
`return document.querySelector("${selector}").querySelector("${innerSelector}").textContent.trim()`);
|
||||
return browser.executeScript(`return document.querySelector("${selector}").querySelector("${
|
||||
innerSelector}").textContent.trim()`);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import {browser} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('jsonp', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('fetching', function() {
|
||||
@ -25,6 +24,6 @@ describe('jsonp', function() {
|
||||
});
|
||||
|
||||
function getComponentText(selector: string, innerSelector: string) {
|
||||
return browser.executeScript(
|
||||
`return document.querySelector("${selector}").querySelector("${innerSelector}").textContent.trim()`);
|
||||
return browser.executeScript(`return document.querySelector("${selector}").querySelector("${
|
||||
innerSelector}").textContent.trim()`);
|
||||
}
|
||||
|
@ -13,11 +13,12 @@ import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
const Key = protractor.Key;
|
||||
|
||||
describe('key_events', function() {
|
||||
|
||||
const URL = '/';
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
beforeEach(() => { browser.get(URL); });
|
||||
beforeEach(() => {
|
||||
browser.get(URL);
|
||||
});
|
||||
|
||||
it('should display correct key names', function() {
|
||||
const firstArea = element.all(by.css('.sample-area')).get(0);
|
||||
@ -78,5 +79,4 @@ describe('key_events', function() {
|
||||
secondArea.sendKeys(Key.CONTROL, Key.SHIFT, Key.ENTER);
|
||||
expect(secondArea.getText()).toEqual('');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -11,7 +11,6 @@ import {browser, by, element} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('Model-Driven Forms', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
const URL = '/';
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {$, ExpectedConditions, browser, by, element} from 'protractor';
|
||||
import {$, browser, by, element, ExpectedConditions} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
@ -16,7 +16,6 @@ function waitForElement(selector: string) {
|
||||
}
|
||||
|
||||
describe('relative assets relative-app', () => {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
const URL = '/';
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {$, ExpectedConditions, browser, by, element} from 'protractor';
|
||||
import {$, browser, by, element, ExpectedConditions} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
@ -16,7 +16,6 @@ function waitForElement(selector: string) {
|
||||
}
|
||||
|
||||
describe('routing inbox-app', () => {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('index view', () => {
|
||||
|
@ -11,15 +11,15 @@ import {browser, by, element} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('SVG', function() {
|
||||
|
||||
const URL = '/';
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
beforeEach(() => { browser.get(URL); });
|
||||
beforeEach(() => {
|
||||
browser.get(URL);
|
||||
});
|
||||
|
||||
it('should display SVG component contents', function() {
|
||||
const svgText = element.all(by.css('g text')).get(0);
|
||||
expect(svgText.getText()).toEqual('Hello');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -11,7 +11,6 @@ import {browser, by, element} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('Template-Driven Forms', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
const URL = '/';
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||
import {browser, by, element, ExpectedConditions, protractor} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||
import {browser, by, element, ExpectedConditions, protractor} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||
|
||||
@ -27,7 +27,6 @@ describe('WebWorkers Kitchen Sink', function() {
|
||||
const elem = element(by.css(selector));
|
||||
browser.wait(ExpectedConditions.textToBePresentInElement(elem, 'hello world!'), 5000);
|
||||
expect(elem.getText()).toEqual('hello world!');
|
||||
|
||||
});
|
||||
|
||||
it('should change greeting', () => {
|
||||
|
@ -6,14 +6,13 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||
import {browser, by, element, ExpectedConditions, protractor} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||
|
||||
const URL = '/';
|
||||
|
||||
describe('MessageBroker', function() {
|
||||
|
||||
afterEach(() => {
|
||||
verifyNoBrowserErrors();
|
||||
browser.ignoreSynchronization = false;
|
||||
|
@ -69,7 +69,9 @@ describe('WebWorker Router', () => {
|
||||
browser.wait(() => {
|
||||
const deferred = protractor.promise.defer();
|
||||
const elem = element(by.css(contentSelector));
|
||||
elem.getText().then((text: string) => { return deferred.fulfill(text === expected); });
|
||||
elem.getText().then((text: string) => {
|
||||
return deferred.fulfill(text === expected);
|
||||
});
|
||||
return deferred.promise;
|
||||
}, 5000);
|
||||
}
|
||||
@ -77,8 +79,9 @@ describe('WebWorker Router', () => {
|
||||
function waitForUrl(regex: RegExp): void {
|
||||
browser.wait(() => {
|
||||
const deferred = protractor.promise.defer();
|
||||
browser.getCurrentUrl().then(
|
||||
(url: string) => { return deferred.fulfill(url.match(regex) !== null); });
|
||||
browser.getCurrentUrl().then((url: string) => {
|
||||
return deferred.fulfill(url.match(regex) !== null);
|
||||
});
|
||||
return deferred.promise;
|
||||
}, 5000);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ describe('WebWorkers Todo', function() {
|
||||
waitForBootstrap();
|
||||
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function waitForBootstrap(): void {
|
||||
|
@ -11,13 +11,14 @@ import {browser, by, element} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
|
||||
|
||||
describe('Zippy Component', function() {
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('zippy', function() {
|
||||
const URL = '/';
|
||||
|
||||
beforeEach(function() { browser.get(URL); });
|
||||
beforeEach(function() {
|
||||
browser.get(URL);
|
||||
});
|
||||
|
||||
it('should change the zippy title depending on it\'s state', function() {
|
||||
const zippyTitle = element(by.css('.zippy__title'));
|
||||
|
@ -87,7 +87,9 @@ export class AnimateApp {
|
||||
alert(`backgroundAnimation has ${phase} from ${data['fromState']} to ${data['toState']}`);
|
||||
}
|
||||
|
||||
get state() { return this._state; }
|
||||
get state() {
|
||||
return this._state;
|
||||
}
|
||||
set state(s) {
|
||||
this._state = s;
|
||||
if (s == 'void') {
|
||||
|
@ -43,7 +43,9 @@ class AsyncApplication {
|
||||
multiTimeoutId: any = null;
|
||||
intervalId: any = null;
|
||||
|
||||
increment(): void { this.val1++; }
|
||||
increment(): void {
|
||||
this.val1++;
|
||||
}
|
||||
|
||||
delayedIncrement(): void {
|
||||
this.cancelDelayedIncrement();
|
||||
|
@ -16,11 +16,17 @@ class GesturesCmp {
|
||||
pinchScale: number = 1;
|
||||
rotateAngle: number = 0;
|
||||
|
||||
onSwipe(event: HammerInput): void { this.swipeDirection = event.deltaX > 0 ? 'right' : 'left'; }
|
||||
onSwipe(event: HammerInput): void {
|
||||
this.swipeDirection = event.deltaX > 0 ? 'right' : 'left';
|
||||
}
|
||||
|
||||
onPinch(event: HammerInput): void { this.pinchScale = event.scale; }
|
||||
onPinch(event: HammerInput): void {
|
||||
this.pinchScale = event.scale;
|
||||
}
|
||||
|
||||
onRotate(event: HammerInput): void { this.rotateAngle = event.rotation; }
|
||||
onRotate(event: HammerInput): void {
|
||||
this.rotateAngle = event.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({declarations: [GesturesCmp], bootstrap: [GesturesCmp], imports: [BrowserModule]})
|
||||
|
@ -48,9 +48,13 @@ export class RedDec {
|
||||
export class HelloCmp {
|
||||
greeting: string;
|
||||
|
||||
constructor(service: GreetingService) { this.greeting = service.greeting; }
|
||||
constructor(service: GreetingService) {
|
||||
this.greeting = service.greeting;
|
||||
}
|
||||
|
||||
changeGreeting(): void { this.greeting = 'howdy'; }
|
||||
changeGreeting(): void {
|
||||
this.greeting = 'howdy';
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({declarations: [HelloCmp, RedDec], bootstrap: [HelloCmp], imports: [BrowserModule]})
|
||||
|
@ -36,7 +36,9 @@ export class KeyEventsApp {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
resetShiftEnter(): void { this.shiftEnter = false; }
|
||||
resetShiftEnter(): void {
|
||||
this.shiftEnter = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a more readable version of current pressed keys.
|
||||
|
@ -52,7 +52,9 @@ export class ShowError {
|
||||
controlPath: string;
|
||||
errorTypes: string[];
|
||||
|
||||
constructor(@Host() formDir: FormGroupDirective) { this.formDir = formDir; }
|
||||
constructor(@Host() formDir: FormGroupDirective) {
|
||||
this.formDir = formDir;
|
||||
}
|
||||
|
||||
get errorMessage(): string {
|
||||
const form: FormGroup = this.formDir.form;
|
||||
|
@ -23,7 +23,9 @@ class OrderItem {
|
||||
public orderItemId: number, public orderId: number, public productName: string,
|
||||
public qty: number, public unitPrice: number) {}
|
||||
|
||||
get total(): number { return this.qty * this.unitPrice; }
|
||||
get total(): number {
|
||||
return this.qty * this.unitPrice;
|
||||
}
|
||||
}
|
||||
|
||||
class Order {
|
||||
@ -31,8 +33,12 @@ class Order {
|
||||
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); }
|
||||
get items(): OrderItem[] {
|
||||
return this._dataService.itemsFor(this);
|
||||
}
|
||||
get total(): number {
|
||||
return this.items.map(i => i.total).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +75,9 @@ export class DataService {
|
||||
this.orderItems.push(new OrderItem(_nextId++, order.orderId, '', 0, 0));
|
||||
}
|
||||
|
||||
deleteItem(item: OrderItem): void { this.orderItems.splice(this.orderItems.indexOf(item), 1); }
|
||||
deleteItem(item: OrderItem): void {
|
||||
this.orderItems.splice(this.orderItems.indexOf(item), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -107,8 +115,12 @@ export class DataService {
|
||||
export class OrderListComponent {
|
||||
orders: Order[];
|
||||
|
||||
constructor(private _service: DataService) { this.orders = _service.orders; }
|
||||
select(order: Order): void { this._service.currentOrder = order; }
|
||||
constructor(private _service: DataService) {
|
||||
this.orders = _service.orders;
|
||||
}
|
||||
select(order: Order): void {
|
||||
this._service.currentOrder = order;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +153,9 @@ export class OrderItemComponent {
|
||||
@Input() item: OrderItem;
|
||||
@Output() delete = new EventEmitter();
|
||||
|
||||
onDelete(): void { this.delete.emit(this.item); }
|
||||
onDelete(): void {
|
||||
this.delete.emit(this.item);
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -176,11 +190,17 @@ export class OrderItemComponent {
|
||||
export class OrderDetailsComponent {
|
||||
constructor(private _service: DataService) {}
|
||||
|
||||
get order(): Order { return this._service.currentOrder; }
|
||||
get order(): Order {
|
||||
return this._service.currentOrder;
|
||||
}
|
||||
|
||||
deleteItem(item: OrderItem): void { this._service.deleteItem(item); }
|
||||
deleteItem(item: OrderItem): void {
|
||||
this._service.deleteItem(item);
|
||||
}
|
||||
|
||||
addItem(): void { this._service.addItemForOrder(this.order); }
|
||||
addItem(): void {
|
||||
this._service.addItemForOrder(this.order);
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -35,9 +35,15 @@ class Person {
|
||||
this.personId = _nextId++;
|
||||
}
|
||||
|
||||
get age(): number { return 2015 - this.yearOfBirth; }
|
||||
get fullName(): string { return `${this.firstName} ${this.lastName}`; }
|
||||
get friendNames(): string { return this.friends.map(f => f.fullName).join(', '); }
|
||||
get age(): number {
|
||||
return 2015 - this.yearOfBirth;
|
||||
}
|
||||
get fullName(): string {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
}
|
||||
get friendNames(): string {
|
||||
return this.friends.map(f => f.fullName).join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +112,9 @@ export class DataService {
|
||||
})
|
||||
export class FullNameComponent {
|
||||
constructor(private _service: DataService) {}
|
||||
get person(): Person { return this._service.currentPerson; }
|
||||
get person(): Person {
|
||||
return this._service.currentPerson;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -158,7 +166,9 @@ export class FullNameComponent {
|
||||
})
|
||||
export class PersonsDetailComponent {
|
||||
constructor(private _service: DataService) {}
|
||||
get person(): Person { return this._service.currentPerson; }
|
||||
get person(): Person {
|
||||
return this._service.currentPerson;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -179,9 +189,13 @@ export class PersonsDetailComponent {
|
||||
export class PersonsComponent {
|
||||
persons: Person[];
|
||||
|
||||
constructor(private _service: DataService) { this.persons = _service.persons; }
|
||||
constructor(private _service: DataService) {
|
||||
this.persons = _service.persons;
|
||||
}
|
||||
|
||||
select(person: Person): void { this._service.currentPerson = person; }
|
||||
select(person: Person): void {
|
||||
this._service.currentPerson = person;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -199,8 +213,12 @@ export class PersonsComponent {
|
||||
export class PersonManagementApplication {
|
||||
mode: string;
|
||||
|
||||
switchToEditName(): void { this.mode = 'editName'; }
|
||||
switchToPersonList(): void { this.mode = 'personList'; }
|
||||
switchToEditName(): void {
|
||||
this.mode = 'editName';
|
||||
}
|
||||
switchToPersonList(): void {
|
||||
this.mode = 'personList';
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
|
@ -29,7 +29,8 @@ export class InboxRecord {
|
||||
email: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
date: string, draft?: boolean
|
||||
date: string,
|
||||
draft?: boolean
|
||||
} = null) {
|
||||
if (data) {
|
||||
this.setData(data);
|
||||
@ -43,7 +44,8 @@ export class InboxRecord {
|
||||
email: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
date: string, draft?: boolean
|
||||
date: string,
|
||||
draft?: boolean
|
||||
}) {
|
||||
this.id = record.id;
|
||||
this.subject = record.subject;
|
||||
|
@ -17,8 +17,11 @@ export class InboxDetailCmp {
|
||||
private ready: boolean = false;
|
||||
|
||||
constructor(db: DbService, route: ActivatedRoute) {
|
||||
route.paramMap.forEach(
|
||||
p => { db.email(p.get('id')).then((data) => { this.record.setData(data); }); });
|
||||
route.paramMap.forEach(p => {
|
||||
db.email(p.get('id')).then((data) => {
|
||||
this.record.setData(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,9 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
<button class="errorButton" (click)="createError()">create error</button>`
|
||||
})
|
||||
export class ErrorComponent {
|
||||
createError(): void { throw new Error('Sourcemap test'); }
|
||||
createError(): void {
|
||||
throw new Error('Sourcemap test');
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({declarations: [ErrorComponent], bootstrap: [ErrorComponent], imports: [BrowserModule]})
|
||||
|
@ -78,7 +78,9 @@ export class ShowError {
|
||||
controlPath: string;
|
||||
errorTypes: string[];
|
||||
|
||||
constructor(@Host() formDir: NgForm) { this.formDir = formDir; }
|
||||
constructor(@Host() formDir: NgForm) {
|
||||
this.formDir = formDir;
|
||||
}
|
||||
|
||||
get errorMessage(): string {
|
||||
const form: FormGroup = this.formDir.form;
|
||||
|
@ -14,14 +14,18 @@ export abstract class KeyModel {
|
||||
}
|
||||
|
||||
export class Todo extends KeyModel {
|
||||
constructor(key: number, public title: string, public completed: boolean) { super(key); }
|
||||
constructor(key: number, public title: string, public completed: boolean) {
|
||||
super(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TodoFactory {
|
||||
private _uid: number = 0;
|
||||
|
||||
nextUid(): number { return ++this._uid; }
|
||||
nextUid(): number {
|
||||
return ++this._uid;
|
||||
}
|
||||
|
||||
create(title: string, isCompleted: boolean): Todo {
|
||||
return new Todo(this.nextUid(), title, isCompleted);
|
||||
@ -33,9 +37,13 @@ export class TodoFactory {
|
||||
export class Store<T extends KeyModel> {
|
||||
list: T[] = [];
|
||||
|
||||
add(record: T): void { this.list.push(record); }
|
||||
add(record: T): void {
|
||||
this.list.push(record);
|
||||
}
|
||||
|
||||
remove(record: T): void { this.removeBy((item) => item === record); }
|
||||
remove(record: T): void {
|
||||
this.removeBy((item) => item === record);
|
||||
}
|
||||
|
||||
removeBy(callback: (record: T) => boolean): void {
|
||||
this.list = this.list.filter((record) => !callback(record));
|
||||
|
@ -23,7 +23,9 @@ export class TodoApp {
|
||||
inputElement.value = '';
|
||||
}
|
||||
|
||||
editTodo(todo: Todo): void { this.todoEdit = todo; }
|
||||
editTodo(todo: Todo): void {
|
||||
this.todoEdit = todo;
|
||||
}
|
||||
|
||||
doneEditing($event: KeyboardEvent, todo: Todo): void {
|
||||
const which = $event.which;
|
||||
@ -37,18 +39,28 @@ export class TodoApp {
|
||||
}
|
||||
}
|
||||
|
||||
addTodo(newTitle: string): void { this.todoStore.add(this.factory.create(newTitle, false)); }
|
||||
addTodo(newTitle: string): void {
|
||||
this.todoStore.add(this.factory.create(newTitle, false));
|
||||
}
|
||||
|
||||
completeMe(todo: Todo): void { todo.completed = !todo.completed; }
|
||||
completeMe(todo: Todo): void {
|
||||
todo.completed = !todo.completed;
|
||||
}
|
||||
|
||||
deleteMe(todo: Todo): void { this.todoStore.remove(todo); }
|
||||
deleteMe(todo: Todo): void {
|
||||
this.todoStore.remove(todo);
|
||||
}
|
||||
|
||||
toggleAll($event: MouseEvent): void {
|
||||
const isComplete = ($event.target as HTMLInputElement).checked;
|
||||
this.todoStore.list.forEach((todo: Todo) => { todo.completed = isComplete; });
|
||||
this.todoStore.list.forEach((todo: Todo) => {
|
||||
todo.completed = isComplete;
|
||||
});
|
||||
}
|
||||
|
||||
clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); }
|
||||
clearCompleted(): void {
|
||||
this.todoStore.removeBy((todo: Todo) => todo.completed);
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({declarations: [TodoApp], bootstrap: [TodoApp], imports: [BrowserModule]})
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, EventEmitter, Input, NgModule, Output, forwardRef} from '@angular/core';
|
||||
import {Component, EventEmitter, forwardRef, Input, NgModule, Output} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {UpgradeAdapter} from '@angular/upgrade';
|
||||
|
||||
@ -30,7 +30,9 @@ const styles = [`
|
||||
const adapter = new UpgradeAdapter(forwardRef(() => Ng2AppModule));
|
||||
const ng1module = angular.module('myExample', []);
|
||||
|
||||
ng1module.controller('Index', function($scope: any) { $scope.name = 'World'; });
|
||||
ng1module.controller('Index', function($scope: any) {
|
||||
$scope.name = 'World';
|
||||
});
|
||||
|
||||
ng1module.directive('ng1User', function() {
|
||||
return {
|
||||
|
@ -26,7 +26,11 @@ export class InputCmp {
|
||||
inputVal = '';
|
||||
textareaVal = '';
|
||||
|
||||
inputChanged(e: Event) { this.inputVal = (e.target as HTMLInputElement).value; }
|
||||
inputChanged(e: Event) {
|
||||
this.inputVal = (e.target as HTMLInputElement).value;
|
||||
}
|
||||
|
||||
textAreaChanged(e: Event) { this.textareaVal = (e.target as HTMLTextAreaElement).value; }
|
||||
textAreaChanged(e: Event) {
|
||||
this.textareaVal = (e.target as HTMLTextAreaElement).value;
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,15 @@ export class HelloCmp {
|
||||
greeting: string;
|
||||
lastKey: string = '(none)';
|
||||
|
||||
constructor(service: GreetingService) { this.greeting = service.greeting; }
|
||||
constructor(service: GreetingService) {
|
||||
this.greeting = service.greeting;
|
||||
}
|
||||
|
||||
changeGreeting(): void { this.greeting = 'howdy'; }
|
||||
changeGreeting(): void {
|
||||
this.greeting = 'howdy';
|
||||
}
|
||||
|
||||
onKeyDown(event: KeyboardEvent): void { this.lastKey = String.fromCharCode(event.keyCode); }
|
||||
onKeyDown(event: KeyboardEvent): void {
|
||||
this.lastKey = String.fromCharCode(event.keyCode);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {PlatformRef} from '@angular/core';
|
||||
import {ClientMessageBrokerFactory, FnArg, SerializerTypes, UiArguments, bootstrapWorkerUi} from '@angular/platform-webworker';
|
||||
import {bootstrapWorkerUi, ClientMessageBrokerFactory, FnArg, SerializerTypes, UiArguments} from '@angular/platform-webworker';
|
||||
|
||||
const ECHO_CHANNEL = 'ECHO';
|
||||
|
||||
|
@ -19,5 +19,7 @@ export class App {
|
||||
'echo', [SerializerTypes.PRIMITIVE], this._echo, SerializerTypes.PRIMITIVE);
|
||||
}
|
||||
|
||||
private _echo(val: string) { return new Promise((res) => res(val)); }
|
||||
private _echo(val: string) {
|
||||
return new Promise((res) => res(val));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WORKER_UI_LOCATION_PROVIDERS, bootstrapWorkerUi} from '@angular/platform-webworker';
|
||||
import {bootstrapWorkerUi, WORKER_UI_LOCATION_PROVIDERS} from '@angular/platform-webworker';
|
||||
|
||||
bootstrapWorkerUi('loader.js', WORKER_UI_LOCATION_PROVIDERS);
|
||||
|
@ -36,11 +36,17 @@ export class TodoApp {
|
||||
}
|
||||
}
|
||||
|
||||
editTodo(todo: Todo): void { this.todoEdit = todo; }
|
||||
editTodo(todo: Todo): void {
|
||||
this.todoEdit = todo;
|
||||
}
|
||||
|
||||
addTodo(newTitle: string): void { this.todoStore.add(this.factory.create(newTitle, false)); }
|
||||
addTodo(newTitle: string): void {
|
||||
this.todoStore.add(this.factory.create(newTitle, false));
|
||||
}
|
||||
|
||||
completeMe(todo: Todo): void { todo.completed = !todo.completed; }
|
||||
completeMe(todo: Todo): void {
|
||||
todo.completed = !todo.completed;
|
||||
}
|
||||
|
||||
toggleCompleted(): void {
|
||||
this.hideActive = !this.hideActive;
|
||||
@ -57,12 +63,18 @@ export class TodoApp {
|
||||
this.hideActive = false;
|
||||
}
|
||||
|
||||
deleteMe(todo: Todo): void { this.todoStore.remove(todo); }
|
||||
deleteMe(todo: Todo): void {
|
||||
this.todoStore.remove(todo);
|
||||
}
|
||||
|
||||
toggleAll($event: MouseEvent): void {
|
||||
this.isComplete = !this.isComplete;
|
||||
this.todoStore.list.forEach((todo: Todo) => { todo.completed = this.isComplete; });
|
||||
this.todoStore.list.forEach((todo: Todo) => {
|
||||
todo.completed = this.isComplete;
|
||||
});
|
||||
}
|
||||
|
||||
clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); }
|
||||
clearCompleted(): void {
|
||||
this.todoStore.removeBy((todo: Todo) => todo.completed);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ export class Todo extends KeyModel {
|
||||
export class TodoFactory {
|
||||
private _uid: number = 0;
|
||||
|
||||
nextUid(): number { return ++this._uid; }
|
||||
nextUid(): number {
|
||||
return ++this._uid;
|
||||
}
|
||||
|
||||
create(title: string, isCompleted: boolean): Todo {
|
||||
return new Todo(this.nextUid(), title, isCompleted);
|
||||
@ -37,9 +39,13 @@ export class TodoFactory {
|
||||
export class Store<T extends KeyModel> {
|
||||
list: T[] = [];
|
||||
|
||||
add(record: T): void { this.list.push(record); }
|
||||
add(record: T): void {
|
||||
this.list.push(record);
|
||||
}
|
||||
|
||||
remove(record: T): void { this.removeBy((item) => item === record); }
|
||||
remove(record: T): void {
|
||||
this.removeBy((item) => item === record);
|
||||
}
|
||||
|
||||
removeBy(callback: (record: T) => boolean): void {
|
||||
this.list = this.list.filter((record) => !callback(record));
|
||||
|
@ -26,7 +26,9 @@ import {Zippy} from './app/zippy';
|
||||
export class ZippyApp {
|
||||
logs: string[] = [];
|
||||
|
||||
pushLog(log: string) { this.logs.push(log); }
|
||||
pushLog(log: string) {
|
||||
this.logs.push(log);
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({declarations: [ZippyApp, Zippy], bootstrap: [ZippyApp], imports: [BrowserModule]})
|
||||
|
Reference in New Issue
Block a user