From fce8e1b1cf76d4a7d66c09df3eacb9f62a6008d5 Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Tue, 22 Mar 2016 15:41:57 -0600 Subject: [PATCH 1/7] Introduction --- Angular2-quickstart/.gitignore | 70 ++ Angular2-quickstart/app/app.component.js | 43 ++ Angular2-quickstart/app/app.component.js.map | 1 + Angular2-quickstart/app/app.component.ts | 26 + Angular2-quickstart/app/main.js | 18 + Angular2-quickstart/app/main.js.map | 1 + Angular2-quickstart/app/main.ts | 4 + Angular2-quickstart/index.html | 37 + Angular2-quickstart/package.json | 28 + Angular2-quickstart/tsconfig.json | 17 + Angular2-quickstart/typings.json | 6 + Angular2-quickstart/typings/browser.d.ts | 2 + .../browser/ambient/es6-shim/es6-shim.d.ts | 670 ++++++++++++++++++ .../browser/ambient/jasmine/jasmine.d.ts | 498 +++++++++++++ Angular2-quickstart/typings/main.d.ts | 2 + .../main/ambient/es6-shim/es6-shim.d.ts | 670 ++++++++++++++++++ .../typings/main/ambient/jasmine/jasmine.d.ts | 498 +++++++++++++ 17 files changed, 2591 insertions(+) create mode 100644 Angular2-quickstart/.gitignore create mode 100644 Angular2-quickstart/app/app.component.js create mode 100644 Angular2-quickstart/app/app.component.js.map create mode 100644 Angular2-quickstart/app/app.component.ts create mode 100644 Angular2-quickstart/app/main.js create mode 100644 Angular2-quickstart/app/main.js.map create mode 100644 Angular2-quickstart/app/main.ts create mode 100644 Angular2-quickstart/index.html create mode 100644 Angular2-quickstart/package.json create mode 100644 Angular2-quickstart/tsconfig.json create mode 100644 Angular2-quickstart/typings.json create mode 100644 Angular2-quickstart/typings/browser.d.ts create mode 100644 Angular2-quickstart/typings/browser/ambient/es6-shim/es6-shim.d.ts create mode 100644 Angular2-quickstart/typings/browser/ambient/jasmine/jasmine.d.ts create mode 100644 Angular2-quickstart/typings/main.d.ts create mode 100644 Angular2-quickstart/typings/main/ambient/es6-shim/es6-shim.d.ts create mode 100644 Angular2-quickstart/typings/main/ambient/jasmine/jasmine.d.ts diff --git a/Angular2-quickstart/.gitignore b/Angular2-quickstart/.gitignore new file mode 100644 index 0000000..beb6ce3 --- /dev/null +++ b/Angular2-quickstart/.gitignore @@ -0,0 +1,70 @@ + +# Created by https://www.gitignore.io/api/osx + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + + +# Created by https://www.gitignore.io/api/node + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js new file mode 100644 index 0000000..f616708 --- /dev/null +++ b/Angular2-quickstart/app/app.component.js @@ -0,0 +1,43 @@ +System.register(['angular2/core'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1; + var AppComponent; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }], + execute: function() { + hero: Hero = { + id: 1, + name: 'Windstorm' + }; + AppComponent = (function () { + function AppComponent() { + this.title = 'Tour of Heroes'; + this.hero = 'Windstorm'; + } + AppComponent = __decorate([ + core_1.Component({ + selector: 'my-app', + template: "\n

{{title}}

\n

{{hero.name}} details!

\n
{{hero.id}}
\n
{{hero.name}}
\n " + }), + __metadata('design:paramtypes', []) + ], AppComponent); + return AppComponent; + }()); + exports_1("AppComponent", AppComponent); + } + } +}); +//# sourceMappingURL=app.component.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map new file mode 100644 index 0000000..b372c70 --- /dev/null +++ b/Angular2-quickstart/app/app.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAOO,IAAI,EAAE,IAAI,GAAG;gBAClB,EAAE,EAAE,CAAC;gBACL,IAAI,EAAE,WAAW;aAClB,CAAC;YAYF;gBAAA;oBACS,UAAK,GAAG,gBAAgB,CAAC;oBACzB,SAAI,GAAG,WAAW,CAAC;gBAC5B,CAAC;gBAZD;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,iLAKN;qBACN,CAAC;;gCAAA;gBAIF,mBAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uCAGC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts new file mode 100644 index 0000000..6eaa9b7 --- /dev/null +++ b/Angular2-quickstart/app/app.component.ts @@ -0,0 +1,26 @@ +import {Component} from 'angular2/core'; + +interface Hero { + id: number; + name: string; +} + +public hero: Hero = { + id: 1, + name: 'Windstorm' +}; + + +@Component({ + selector: 'my-app', + template:` +

{{title}}

+

{{hero.name}} details!

+
{{hero.id}}
+
{{hero.name}}
+ ` +}) +export class AppComponent { + public title = 'Tour of Heroes'; + public hero = 'Windstorm'; +} diff --git a/Angular2-quickstart/app/main.js b/Angular2-quickstart/app/main.js new file mode 100644 index 0000000..a4fa928 --- /dev/null +++ b/Angular2-quickstart/app/main.js @@ -0,0 +1,18 @@ +System.register(['angular2/platform/browser', './app.component'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var browser_1, app_component_1; + return { + setters:[ + function (browser_1_1) { + browser_1 = browser_1_1; + }, + function (app_component_1_1) { + app_component_1 = app_component_1_1; + }], + execute: function() { + browser_1.bootstrap(app_component_1.AppComponent); + } + } +}); +//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/main.js.map b/Angular2-quickstart/app/main.js.map new file mode 100644 index 0000000..9942b50 --- /dev/null +++ b/Angular2-quickstart/app/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;;;;;;;;;;;;YAGA,mBAAS,CAAC,4BAAY,CAAC,CAAC"} \ No newline at end of file diff --git a/Angular2-quickstart/app/main.ts b/Angular2-quickstart/app/main.ts new file mode 100644 index 0000000..034c155 --- /dev/null +++ b/Angular2-quickstart/app/main.ts @@ -0,0 +1,4 @@ +import {bootstrap} from 'angular2/platform/browser' +import {AppComponent} from './app.component' + +bootstrap(AppComponent); diff --git a/Angular2-quickstart/index.html b/Angular2-quickstart/index.html new file mode 100644 index 0000000..fdc480a --- /dev/null +++ b/Angular2-quickstart/index.html @@ -0,0 +1,37 @@ + + + Angular 2 QuickStart + + + + + + + + + + + + + + + + + + + + + Loading... + + diff --git a/Angular2-quickstart/package.json b/Angular2-quickstart/package.json new file mode 100644 index 0000000..5160703 --- /dev/null +++ b/Angular2-quickstart/package.json @@ -0,0 +1,28 @@ +{ + "name": "angular2-quickstart", + "version": "1.0.0", + "scripts": { + "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", + "tsc": "tsc", + "tsc:w": "tsc -w", + "lite": "lite-server", + "typings": "typings", + "postinstall": "typings install" + }, + "license": "ISC", + "dependencies": { + "angular2": "2.0.0-beta.8", + "systemjs": "0.19.22", + "es6-promise": "^3.0.2", + "es6-shim": "^0.33.3", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.2", + "zone.js": "0.5.15" + }, + "devDependencies": { + "concurrently": "^2.0.0", + "lite-server": "^2.1.0", + "typescript": "^1.8.2", + "typings":"^0.6.8" + } +} diff --git a/Angular2-quickstart/tsconfig.json b/Angular2-quickstart/tsconfig.json new file mode 100644 index 0000000..9be71e4 --- /dev/null +++ b/Angular2-quickstart/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false, + "noImplicitAny": false + }, + "exclude": [ + "node_modules", + "typings/main", + "typings/main.d.ts" + ] +} diff --git a/Angular2-quickstart/typings.json b/Angular2-quickstart/typings.json new file mode 100644 index 0000000..f10b7c5 --- /dev/null +++ b/Angular2-quickstart/typings.json @@ -0,0 +1,6 @@ +{ + "ambientDependencies": { + "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c", + "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#bc92442c075929849ec41d28ab618892ba493504" + } +} diff --git a/Angular2-quickstart/typings/browser.d.ts b/Angular2-quickstart/typings/browser.d.ts new file mode 100644 index 0000000..5d213f7 --- /dev/null +++ b/Angular2-quickstart/typings/browser.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/Angular2-quickstart/typings/browser/ambient/es6-shim/es6-shim.d.ts b/Angular2-quickstart/typings/browser/ambient/es6-shim/es6-shim.d.ts new file mode 100644 index 0000000..50f2134 --- /dev/null +++ b/Angular2-quickstart/typings/browser/ambient/es6-shim/es6-shim.d.ts @@ -0,0 +1,670 @@ +// Compiled using typings@0.6.10 +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts +// Type definitions for es6-shim v0.31.2 +// Project: https://github.com/paulmillr/es6-shim +// Definitions by: Ron Buckton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare type PropertyKey = string | number | symbol; + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface IterableShim { + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): Iterator; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface IterableIteratorShim extends IterableShim, Iterator { + /** + * Shim for an ES6 iterable iterator. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface String { + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; + + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: IterableShim): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIteratorShim<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIteratorShim; + + /** + * Returns an list of values in the array + */ + values(): IterableIteratorShim; + + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + * @remarks Requires `__proto__` support. + */ + setPrototypeOf(o: any, proto: any): any; +} + +interface RegExp { + /** + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + flags: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[]): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; +} + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: IterableShim>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: IterableShim>): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): Map; + size: number; + entries(): IterableIteratorShim<[K, V]>; + keys(): IterableIteratorShim; + values(): IterableIteratorShim; +} + +interface MapConstructor { + new (): Map; + new (iterable: IterableShim<[K, V]>): Map; + prototype: Map; +} + +declare var Map: MapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; + entries(): IterableIteratorShim<[T, T]>; + keys(): IterableIteratorShim; + values(): IterableIteratorShim; +} + +interface SetConstructor { + new (): Set; + new (iterable: IterableShim): Set; + prototype: Set; +} + +declare var Set: SetConstructor; + +interface WeakMap { + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: IterableShim<[K, V]>): WeakMap; + prototype: WeakMap; +} + +declare var WeakMap: WeakMapConstructor; + +interface WeakSet { + add(value: T): WeakSet; + delete(value: T): boolean; + has(value: T): boolean; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: IterableShim): WeakSet; + prototype: WeakSet; +} + +declare var WeakSet: WeakSetConstructor; + +declare module Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike): any; + function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function enumerate(target: any): IterableIteratorShim; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: PropertyKey): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; +} + +declare module "es6-shim" { + var String: StringConstructor; + var Array: ArrayConstructor; + var Number: NumberConstructor; + var Math: Math; + var Object: ObjectConstructor; + var Map: MapConstructor; + var Set: SetConstructor; + var WeakMap: WeakMapConstructor; + var WeakSet: WeakSetConstructor; + var Promise: PromiseConstructor; + module Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike): any; + function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function enumerate(target: any): Iterator; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: PropertyKey): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; + } +} \ No newline at end of file diff --git a/Angular2-quickstart/typings/browser/ambient/jasmine/jasmine.d.ts b/Angular2-quickstart/typings/browser/ambient/jasmine/jasmine.d.ts new file mode 100644 index 0000000..ce35227 --- /dev/null +++ b/Angular2-quickstart/typings/browser/ambient/jasmine/jasmine.d.ts @@ -0,0 +1,498 @@ +// Compiled using typings@0.6.10 +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/bc92442c075929849ec41d28ab618892ba493504/jasmine/jasmine.d.ts +// Type definitions for Jasmine 2.2 +// Project: http://jasmine.github.io/ +// Definitions by: Boris Yankov , Theodore Brown , David Pärsson +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts + +declare function describe(description: string, specDefinitions: () => void): void; +declare function fdescribe(description: string, specDefinitions: () => void): void; +declare function xdescribe(description: string, specDefinitions: () => void): void; + +declare function it(expectation: string, assertion?: () => void, timeout?: number): void; +declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; + +/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ +declare function pending(reason?: string): void; + +declare function beforeEach(action: () => void, timeout?: number): void; +declare function beforeEach(action: (done: () => void) => void, timeout?: number): void; +declare function afterEach(action: () => void, timeout?: number): void; +declare function afterEach(action: (done: () => void) => void, timeout?: number): void; + +declare function beforeAll(action: () => void, timeout?: number): void; +declare function beforeAll(action: (done: () => void) => void, timeout?: number): void; +declare function afterAll(action: () => void, timeout?: number): void; +declare function afterAll(action: (done: () => void) => void, timeout?: number): void; + +declare function expect(spy: Function): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; + +declare function fail(e?: any): void; + +declare function spyOn(object: any, method: string): jasmine.Spy; + +declare function runs(asyncMethod: Function): void; +declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; +declare function waits(timeout?: number): void; + +declare module jasmine { + + var clock: () => Clock; + + function any(aclass: any): Any; + function anything(): Any; + function arrayContaining(sample: any[]): ArrayContaining; + function objectContaining(sample: any): ObjectContaining; + function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; + function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + function addMatchers(matchers: CustomMatcherFactories): void; + function stringMatching(str: string): Any; + function stringMatching(str: RegExp): Any; + + interface Any { + + new (expectedClass: any): any; + + jasmineMatches(other: any): boolean; + jasmineToString(): string; + } + + // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() + interface ArrayLike { + length: number; + [n: number]: T; + } + + interface ArrayContaining { + new (sample: any[]): any; + + asymmetricMatch(other: any): boolean; + jasmineToString(): string; + } + + interface ObjectContaining { + new (sample: any): any; + + jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; + jasmineToString(): string; + } + + interface Block { + + new (env: Env, func: SpecFunction, spec: Spec): any; + + execute(onComplete: () => void): void; + } + + interface WaitsBlock extends Block { + new (env: Env, timeout: number, spec: Spec): any; + } + + interface WaitsForBlock extends Block { + new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; + } + + interface Clock { + install(): void; + uninstall(): void; + /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ + tick(ms: number): void; + mockDate(date?: Date): void; + } + + interface CustomEqualityTester { + (first: any, second: any): boolean; + } + + interface CustomMatcher { + compare(actual: T, expected: T): CustomMatcherResult; + compare(actual: any, expected: any): CustomMatcherResult; + } + + interface CustomMatcherFactory { + (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; + } + + interface CustomMatcherFactories { + [index: string]: CustomMatcherFactory; + } + + interface CustomMatcherResult { + pass: boolean; + message?: string; + } + + interface MatchersUtil { + equals(a: any, b: any, customTesters?: Array): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; + buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; + } + + interface Env { + setTimeout: any; + clearTimeout: void; + setInterval: any; + clearInterval: void; + updateInterval: number; + + currentSpec: Spec; + + matchersClass: Matchers; + + version(): any; + versionString(): string; + nextSpecId(): number; + addReporter(reporter: Reporter): void; + execute(): void; + describe(description: string, specDefinitions: () => void): Suite; + // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these + beforeEach(beforeEachFunction: () => void): void; + beforeAll(beforeAllFunction: () => void): void; + currentRunner(): Runner; + afterEach(afterEachFunction: () => void): void; + afterAll(afterAllFunction: () => void): void; + xdescribe(desc: string, specDefinitions: () => void): XSuite; + it(description: string, func: () => void): Spec; + // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these + xit(desc: string, func: () => void): XSpec; + compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; + compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + contains_(haystack: any, needle: any): boolean; + addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + addMatchers(matchers: CustomMatcherFactories): void; + specFilter(spec: Spec): boolean; + } + + interface FakeTimer { + + new (): any; + + reset(): void; + tick(millis: number): void; + runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; + scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; + } + + interface HtmlReporter { + new (): any; + } + + interface HtmlSpecFilter { + new (): any; + } + + interface Result { + type: string; + } + + interface NestedResults extends Result { + description: string; + + totalCount: number; + passedCount: number; + failedCount: number; + + skipped: boolean; + + rollupCounts(result: NestedResults): void; + log(values: any): void; + getItems(): Result[]; + addResult(result: Result): void; + passed(): boolean; + } + + interface MessageResult extends Result { + values: any; + trace: Trace; + } + + interface ExpectationResult extends Result { + matcherName: string; + passed(): boolean; + expected: any; + actual: any; + message: string; + trace: Trace; + } + + interface Trace { + name: string; + message: string; + stack: any; + } + + interface PrettyPrinter { + + new (): any; + + format(value: any): void; + iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; + emitScalar(value: any): void; + emitString(value: string): void; + emitArray(array: any[]): void; + emitObject(obj: any): void; + append(value: any): void; + } + + interface StringPrettyPrinter extends PrettyPrinter { + } + + interface Queue { + + new (env: any): any; + + env: Env; + ensured: boolean[]; + blocks: Block[]; + running: boolean; + index: number; + offset: number; + abort: boolean; + + addBefore(block: Block, ensure?: boolean): void; + add(block: any, ensure?: boolean): void; + insertNext(block: any, ensure?: boolean): void; + start(onComplete?: () => void): void; + isRunning(): boolean; + next_(): void; + results(): NestedResults; + } + + interface Matchers { + + new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + + env: Env; + actual: any; + spec: Env; + isNot?: boolean; + message(): any; + + toBe(expected: any, expectationFailOutput?: any): boolean; + toEqual(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; + toBeDefined(expectationFailOutput?: any): boolean; + toBeUndefined(expectationFailOutput?: any): boolean; + toBeNull(expectationFailOutput?: any): boolean; + toBeNaN(): boolean; + toBeTruthy(expectationFailOutput?: any): boolean; + toBeFalsy(expectationFailOutput?: any): boolean; + toHaveBeenCalled(): boolean; + toHaveBeenCalledWith(...params: any[]): boolean; + toHaveBeenCalledTimes(expected: number): boolean; + toContain(expected: any, expectationFailOutput?: any): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; + toThrow(expected?: any): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: Error, message?: string | RegExp): boolean; + not: Matchers; + + Any: Any; + } + + interface Reporter { + reportRunnerStarting(runner: Runner): void; + reportRunnerResults(runner: Runner): void; + reportSuiteResults(suite: Suite): void; + reportSpecStarting(spec: Spec): void; + reportSpecResults(spec: Spec): void; + log(str: string): void; + } + + interface MultiReporter extends Reporter { + addReporter(reporter: Reporter): void; + } + + interface Runner { + + new (env: Env): any; + + execute(): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + finishCallback(): void; + addSuite(suite: Suite): void; + add(block: Block): void; + specs(): Spec[]; + suites(): Suite[]; + topLevelSuites(): Suite[]; + results(): NestedResults; + } + + interface SpecFunction { + (spec?: Spec): void; + } + + interface SuiteOrSpec { + id: number; + env: Env; + description: string; + queue: Queue; + } + + interface Spec extends SuiteOrSpec { + + new (env: Env, suite: Suite, description: string): any; + + suite: Suite; + + afterCallbacks: SpecFunction[]; + spies_: Spy[]; + + results_: NestedResults; + matchersClass: Matchers; + + getFullName(): string; + results(): NestedResults; + log(arguments: any): any; + runs(func: SpecFunction): Spec; + addToQueue(block: Block): void; + addMatcherResult(result: Result): void; + expect(actual: any): any; + waits(timeout: number): Spec; + waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; + fail(e?: any): void; + getMatchersClass_(): Matchers; + addMatchers(matchersPrototype: CustomMatcherFactories): void; + finishCallback(): void; + finish(onComplete?: () => void): void; + after(doAfter: SpecFunction): void; + execute(onComplete?: () => void): any; + addBeforesAndAftersToQueue(): void; + explodes(): void; + spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; + removeAllSpies(): void; + } + + interface XSpec { + id: number; + runs(): void; + } + + interface Suite extends SuiteOrSpec { + + new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; + + parentSuite: Suite; + + getFullName(): string; + finish(onComplete?: () => void): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + results(): NestedResults; + add(suiteOrSpec: SuiteOrSpec): void; + specs(): Spec[]; + suites(): Suite[]; + children(): any[]; + execute(onComplete?: () => void): void; + } + + interface XSuite { + execute(): void; + } + + interface Spy { + (...params: any[]): any; + + identity: string; + and: SpyAnd; + calls: Calls; + mostRecentCall: { args: any[]; }; + argsForCall: any[]; + wasCalled: boolean; + } + + interface SpyAnd { + /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ + callThrough(): Spy; + /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ + returnValue(val: any): Spy; + /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ + callFake(fn: Function): Spy; + /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ + throwError(msg: string): Spy; + /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ + stub(): Spy; + } + + interface Calls { + /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ + any(): boolean; + /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ + count(): number; + /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ + argsFor(index: number): any[]; + /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ + allArgs(): any[]; + /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ + all(): CallInfo[]; + /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ + mostRecent(): CallInfo; + /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ + first(): CallInfo; + /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ + reset(): void; + } + + interface CallInfo { + /** The context (the this) for the call */ + object: any; + /** All arguments passed to the call */ + args: any[]; + } + + interface Util { + inherit(childClass: Function, parentClass: Function): any; + formatException(e: any): any; + htmlEscape(str: string): string; + argsToArray(args: any): any; + extend(destination: any, source: any): any; + } + + interface JsApiReporter extends Reporter { + + started: boolean; + finished: boolean; + result: any; + messages: any; + + new (): any; + + suites(): Suite[]; + summarize_(suiteOrSpec: SuiteOrSpec): any; + results(): any; + resultsForSpec(specId: any): any; + log(str: any): any; + resultsForSpecs(specIds: any): any; + summarizeResult_(result: any): any; + } + + interface Jasmine { + Spec: Spec; + clock: Clock; + util: Util; + } + + export var HtmlReporter: HtmlReporter; + export var HtmlSpecFilter: HtmlSpecFilter; + export var DEFAULT_TIMEOUT_INTERVAL: number; +} \ No newline at end of file diff --git a/Angular2-quickstart/typings/main.d.ts b/Angular2-quickstart/typings/main.d.ts new file mode 100644 index 0000000..ad8d621 --- /dev/null +++ b/Angular2-quickstart/typings/main.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/Angular2-quickstart/typings/main/ambient/es6-shim/es6-shim.d.ts b/Angular2-quickstart/typings/main/ambient/es6-shim/es6-shim.d.ts new file mode 100644 index 0000000..50f2134 --- /dev/null +++ b/Angular2-quickstart/typings/main/ambient/es6-shim/es6-shim.d.ts @@ -0,0 +1,670 @@ +// Compiled using typings@0.6.10 +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts +// Type definitions for es6-shim v0.31.2 +// Project: https://github.com/paulmillr/es6-shim +// Definitions by: Ron Buckton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare type PropertyKey = string | number | symbol; + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface IterableShim { + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): Iterator; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface IterableIteratorShim extends IterableShim, Iterator { + /** + * Shim for an ES6 iterable iterator. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface String { + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; + + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: IterableShim): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIteratorShim<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIteratorShim; + + /** + * Returns an list of values in the array + */ + values(): IterableIteratorShim; + + /** + * Shim for an ES6 iterable. Not intended for direct use by user code. + */ + "_es6-shim iterator_"(): IterableIteratorShim; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + * @remarks Requires `__proto__` support. + */ + setPrototypeOf(o: any, proto: any): any; +} + +interface RegExp { + /** + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + flags: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[]): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; +} + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: IterableShim>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: IterableShim>): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): Map; + size: number; + entries(): IterableIteratorShim<[K, V]>; + keys(): IterableIteratorShim; + values(): IterableIteratorShim; +} + +interface MapConstructor { + new (): Map; + new (iterable: IterableShim<[K, V]>): Map; + prototype: Map; +} + +declare var Map: MapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; + entries(): IterableIteratorShim<[T, T]>; + keys(): IterableIteratorShim; + values(): IterableIteratorShim; +} + +interface SetConstructor { + new (): Set; + new (iterable: IterableShim): Set; + prototype: Set; +} + +declare var Set: SetConstructor; + +interface WeakMap { + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: IterableShim<[K, V]>): WeakMap; + prototype: WeakMap; +} + +declare var WeakMap: WeakMapConstructor; + +interface WeakSet { + add(value: T): WeakSet; + delete(value: T): boolean; + has(value: T): boolean; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: IterableShim): WeakSet; + prototype: WeakSet; +} + +declare var WeakSet: WeakSetConstructor; + +declare module Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike): any; + function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function enumerate(target: any): IterableIteratorShim; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: PropertyKey): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; +} + +declare module "es6-shim" { + var String: StringConstructor; + var Array: ArrayConstructor; + var Number: NumberConstructor; + var Math: Math; + var Object: ObjectConstructor; + var Map: MapConstructor; + var Set: SetConstructor; + var WeakMap: WeakMapConstructor; + var WeakSet: WeakSetConstructor; + var Promise: PromiseConstructor; + module Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike): any; + function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function enumerate(target: any): Iterator; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: PropertyKey): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; + } +} \ No newline at end of file diff --git a/Angular2-quickstart/typings/main/ambient/jasmine/jasmine.d.ts b/Angular2-quickstart/typings/main/ambient/jasmine/jasmine.d.ts new file mode 100644 index 0000000..ce35227 --- /dev/null +++ b/Angular2-quickstart/typings/main/ambient/jasmine/jasmine.d.ts @@ -0,0 +1,498 @@ +// Compiled using typings@0.6.10 +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/bc92442c075929849ec41d28ab618892ba493504/jasmine/jasmine.d.ts +// Type definitions for Jasmine 2.2 +// Project: http://jasmine.github.io/ +// Definitions by: Boris Yankov , Theodore Brown , David Pärsson +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts + +declare function describe(description: string, specDefinitions: () => void): void; +declare function fdescribe(description: string, specDefinitions: () => void): void; +declare function xdescribe(description: string, specDefinitions: () => void): void; + +declare function it(expectation: string, assertion?: () => void, timeout?: number): void; +declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; + +/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ +declare function pending(reason?: string): void; + +declare function beforeEach(action: () => void, timeout?: number): void; +declare function beforeEach(action: (done: () => void) => void, timeout?: number): void; +declare function afterEach(action: () => void, timeout?: number): void; +declare function afterEach(action: (done: () => void) => void, timeout?: number): void; + +declare function beforeAll(action: () => void, timeout?: number): void; +declare function beforeAll(action: (done: () => void) => void, timeout?: number): void; +declare function afterAll(action: () => void, timeout?: number): void; +declare function afterAll(action: (done: () => void) => void, timeout?: number): void; + +declare function expect(spy: Function): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; + +declare function fail(e?: any): void; + +declare function spyOn(object: any, method: string): jasmine.Spy; + +declare function runs(asyncMethod: Function): void; +declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; +declare function waits(timeout?: number): void; + +declare module jasmine { + + var clock: () => Clock; + + function any(aclass: any): Any; + function anything(): Any; + function arrayContaining(sample: any[]): ArrayContaining; + function objectContaining(sample: any): ObjectContaining; + function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; + function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + function addMatchers(matchers: CustomMatcherFactories): void; + function stringMatching(str: string): Any; + function stringMatching(str: RegExp): Any; + + interface Any { + + new (expectedClass: any): any; + + jasmineMatches(other: any): boolean; + jasmineToString(): string; + } + + // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() + interface ArrayLike { + length: number; + [n: number]: T; + } + + interface ArrayContaining { + new (sample: any[]): any; + + asymmetricMatch(other: any): boolean; + jasmineToString(): string; + } + + interface ObjectContaining { + new (sample: any): any; + + jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; + jasmineToString(): string; + } + + interface Block { + + new (env: Env, func: SpecFunction, spec: Spec): any; + + execute(onComplete: () => void): void; + } + + interface WaitsBlock extends Block { + new (env: Env, timeout: number, spec: Spec): any; + } + + interface WaitsForBlock extends Block { + new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; + } + + interface Clock { + install(): void; + uninstall(): void; + /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ + tick(ms: number): void; + mockDate(date?: Date): void; + } + + interface CustomEqualityTester { + (first: any, second: any): boolean; + } + + interface CustomMatcher { + compare(actual: T, expected: T): CustomMatcherResult; + compare(actual: any, expected: any): CustomMatcherResult; + } + + interface CustomMatcherFactory { + (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; + } + + interface CustomMatcherFactories { + [index: string]: CustomMatcherFactory; + } + + interface CustomMatcherResult { + pass: boolean; + message?: string; + } + + interface MatchersUtil { + equals(a: any, b: any, customTesters?: Array): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; + buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; + } + + interface Env { + setTimeout: any; + clearTimeout: void; + setInterval: any; + clearInterval: void; + updateInterval: number; + + currentSpec: Spec; + + matchersClass: Matchers; + + version(): any; + versionString(): string; + nextSpecId(): number; + addReporter(reporter: Reporter): void; + execute(): void; + describe(description: string, specDefinitions: () => void): Suite; + // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these + beforeEach(beforeEachFunction: () => void): void; + beforeAll(beforeAllFunction: () => void): void; + currentRunner(): Runner; + afterEach(afterEachFunction: () => void): void; + afterAll(afterAllFunction: () => void): void; + xdescribe(desc: string, specDefinitions: () => void): XSuite; + it(description: string, func: () => void): Spec; + // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these + xit(desc: string, func: () => void): XSpec; + compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; + compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + contains_(haystack: any, needle: any): boolean; + addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + addMatchers(matchers: CustomMatcherFactories): void; + specFilter(spec: Spec): boolean; + } + + interface FakeTimer { + + new (): any; + + reset(): void; + tick(millis: number): void; + runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; + scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; + } + + interface HtmlReporter { + new (): any; + } + + interface HtmlSpecFilter { + new (): any; + } + + interface Result { + type: string; + } + + interface NestedResults extends Result { + description: string; + + totalCount: number; + passedCount: number; + failedCount: number; + + skipped: boolean; + + rollupCounts(result: NestedResults): void; + log(values: any): void; + getItems(): Result[]; + addResult(result: Result): void; + passed(): boolean; + } + + interface MessageResult extends Result { + values: any; + trace: Trace; + } + + interface ExpectationResult extends Result { + matcherName: string; + passed(): boolean; + expected: any; + actual: any; + message: string; + trace: Trace; + } + + interface Trace { + name: string; + message: string; + stack: any; + } + + interface PrettyPrinter { + + new (): any; + + format(value: any): void; + iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; + emitScalar(value: any): void; + emitString(value: string): void; + emitArray(array: any[]): void; + emitObject(obj: any): void; + append(value: any): void; + } + + interface StringPrettyPrinter extends PrettyPrinter { + } + + interface Queue { + + new (env: any): any; + + env: Env; + ensured: boolean[]; + blocks: Block[]; + running: boolean; + index: number; + offset: number; + abort: boolean; + + addBefore(block: Block, ensure?: boolean): void; + add(block: any, ensure?: boolean): void; + insertNext(block: any, ensure?: boolean): void; + start(onComplete?: () => void): void; + isRunning(): boolean; + next_(): void; + results(): NestedResults; + } + + interface Matchers { + + new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + + env: Env; + actual: any; + spec: Env; + isNot?: boolean; + message(): any; + + toBe(expected: any, expectationFailOutput?: any): boolean; + toEqual(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; + toBeDefined(expectationFailOutput?: any): boolean; + toBeUndefined(expectationFailOutput?: any): boolean; + toBeNull(expectationFailOutput?: any): boolean; + toBeNaN(): boolean; + toBeTruthy(expectationFailOutput?: any): boolean; + toBeFalsy(expectationFailOutput?: any): boolean; + toHaveBeenCalled(): boolean; + toHaveBeenCalledWith(...params: any[]): boolean; + toHaveBeenCalledTimes(expected: number): boolean; + toContain(expected: any, expectationFailOutput?: any): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; + toThrow(expected?: any): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: Error, message?: string | RegExp): boolean; + not: Matchers; + + Any: Any; + } + + interface Reporter { + reportRunnerStarting(runner: Runner): void; + reportRunnerResults(runner: Runner): void; + reportSuiteResults(suite: Suite): void; + reportSpecStarting(spec: Spec): void; + reportSpecResults(spec: Spec): void; + log(str: string): void; + } + + interface MultiReporter extends Reporter { + addReporter(reporter: Reporter): void; + } + + interface Runner { + + new (env: Env): any; + + execute(): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + finishCallback(): void; + addSuite(suite: Suite): void; + add(block: Block): void; + specs(): Spec[]; + suites(): Suite[]; + topLevelSuites(): Suite[]; + results(): NestedResults; + } + + interface SpecFunction { + (spec?: Spec): void; + } + + interface SuiteOrSpec { + id: number; + env: Env; + description: string; + queue: Queue; + } + + interface Spec extends SuiteOrSpec { + + new (env: Env, suite: Suite, description: string): any; + + suite: Suite; + + afterCallbacks: SpecFunction[]; + spies_: Spy[]; + + results_: NestedResults; + matchersClass: Matchers; + + getFullName(): string; + results(): NestedResults; + log(arguments: any): any; + runs(func: SpecFunction): Spec; + addToQueue(block: Block): void; + addMatcherResult(result: Result): void; + expect(actual: any): any; + waits(timeout: number): Spec; + waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; + fail(e?: any): void; + getMatchersClass_(): Matchers; + addMatchers(matchersPrototype: CustomMatcherFactories): void; + finishCallback(): void; + finish(onComplete?: () => void): void; + after(doAfter: SpecFunction): void; + execute(onComplete?: () => void): any; + addBeforesAndAftersToQueue(): void; + explodes(): void; + spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; + removeAllSpies(): void; + } + + interface XSpec { + id: number; + runs(): void; + } + + interface Suite extends SuiteOrSpec { + + new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; + + parentSuite: Suite; + + getFullName(): string; + finish(onComplete?: () => void): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + results(): NestedResults; + add(suiteOrSpec: SuiteOrSpec): void; + specs(): Spec[]; + suites(): Suite[]; + children(): any[]; + execute(onComplete?: () => void): void; + } + + interface XSuite { + execute(): void; + } + + interface Spy { + (...params: any[]): any; + + identity: string; + and: SpyAnd; + calls: Calls; + mostRecentCall: { args: any[]; }; + argsForCall: any[]; + wasCalled: boolean; + } + + interface SpyAnd { + /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ + callThrough(): Spy; + /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ + returnValue(val: any): Spy; + /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ + callFake(fn: Function): Spy; + /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ + throwError(msg: string): Spy; + /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ + stub(): Spy; + } + + interface Calls { + /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ + any(): boolean; + /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ + count(): number; + /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ + argsFor(index: number): any[]; + /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ + allArgs(): any[]; + /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ + all(): CallInfo[]; + /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ + mostRecent(): CallInfo; + /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ + first(): CallInfo; + /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ + reset(): void; + } + + interface CallInfo { + /** The context (the this) for the call */ + object: any; + /** All arguments passed to the call */ + args: any[]; + } + + interface Util { + inherit(childClass: Function, parentClass: Function): any; + formatException(e: any): any; + htmlEscape(str: string): string; + argsToArray(args: any): any; + extend(destination: any, source: any): any; + } + + interface JsApiReporter extends Reporter { + + started: boolean; + finished: boolean; + result: any; + messages: any; + + new (): any; + + suites(): Suite[]; + summarize_(suiteOrSpec: SuiteOrSpec): any; + results(): any; + resultsForSpec(specId: any): any; + log(str: any): any; + resultsForSpecs(specIds: any): any; + summarizeResult_(result: any): any; + } + + interface Jasmine { + Spec: Spec; + clock: Clock; + util: Util; + } + + export var HtmlReporter: HtmlReporter; + export var HtmlSpecFilter: HtmlSpecFilter; + export var DEFAULT_TIMEOUT_INTERVAL: number; +} \ No newline at end of file From f8ede1bf589eb5640bfcc82407db3b17134d04d4 Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Tue, 22 Mar 2016 16:04:06 -0600 Subject: [PATCH 2/7] The Hero Editor --- Angular2-quickstart/app/app.component.js | 11 +++++------ Angular2-quickstart/app/app.component.js.map | 2 +- Angular2-quickstart/app/app.component.ts | 16 +++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js index f616708..87dba15 100644 --- a/Angular2-quickstart/app/app.component.js +++ b/Angular2-quickstart/app/app.component.js @@ -18,19 +18,18 @@ System.register(['angular2/core'], function(exports_1, context_1) { core_1 = core_1_1; }], execute: function() { - hero: Hero = { - id: 1, - name: 'Windstorm' - }; AppComponent = (function () { function AppComponent() { this.title = 'Tour of Heroes'; - this.hero = 'Windstorm'; + this.hero = { + id: 1, + name: 'Windstorm' + }; } AppComponent = __decorate([ core_1.Component({ selector: 'my-app', - template: "\n

{{title}}

\n

{{hero.name}} details!

\n
{{hero.id}}
\n
{{hero.name}}
\n " + template: "\n

{{title}}

\n

{{hero.name}} details!

\n
{{hero.id}}
\n
\n \n \n
\n " }), __metadata('design:paramtypes', []) ], AppComponent); diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map index b372c70..2f1820b 100644 --- a/Angular2-quickstart/app/app.component.js.map +++ b/Angular2-quickstart/app/app.component.js.map @@ -1 +1 @@ -{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAOO,IAAI,EAAE,IAAI,GAAG;gBAClB,EAAE,EAAE,CAAC;gBACL,IAAI,EAAE,WAAW;aAClB,CAAC;YAYF;gBAAA;oBACS,UAAK,GAAG,gBAAgB,CAAC;oBACzB,SAAI,GAAG,WAAW,CAAC;gBAC5B,CAAC;gBAZD;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,iLAKN;qBACN,CAAC;;gCAAA;gBAIF,mBAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uCAGC,CAAA"} \ No newline at end of file +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAqBA;gBAAA;oBACS,UAAK,GAAG,gBAAgB,CAAC;oBACzB,SAAI,GAAS;wBAChB,EAAE,EAAE,CAAC;wBACL,IAAI,EAAE,WAAW;qBAClB,CAAC;gBACN,CAAC;gBAnBD;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,sPAQN;qBAEN,CAAC;;gCAAA;gBAOF,mBAAC;YAAD,CAAC,AAND,IAMC;YAND,uCAMC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts index 6eaa9b7..bd70f05 100644 --- a/Angular2-quickstart/app/app.component.ts +++ b/Angular2-quickstart/app/app.component.ts @@ -5,11 +5,6 @@ interface Hero { name: string; } -public hero: Hero = { - id: 1, - name: 'Windstorm' -}; - @Component({ selector: 'my-app', @@ -17,10 +12,17 @@ public hero: Hero = {

{{title}}

{{hero.name}} details!

{{hero.id}}
-
{{hero.name}}
+
+ + +
` + }) export class AppComponent { public title = 'Tour of Heroes'; - public hero = 'Windstorm'; + public hero: Hero = { + id: 1, + name: 'Windstorm' + }; } From d56c21ab0cd6c80808e2b9a5be6d7f976c803796 Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Mon, 28 Mar 2016 06:18:59 -0600 Subject: [PATCH 3/7] MASTER/DETAIL --- Angular2-quickstart/app/app.component.js | 29 ++++-- Angular2-quickstart/app/app.component.js.map | 2 +- Angular2-quickstart/app/app.component.ts | 100 +++++++++++++++---- 3 files changed, 107 insertions(+), 24 deletions(-) diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js index 87dba15..9378ab4 100644 --- a/Angular2-quickstart/app/app.component.js +++ b/Angular2-quickstart/app/app.component.js @@ -11,31 +11,48 @@ System.register(['angular2/core'], function(exports_1, context_1) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var core_1; - var AppComponent; + var Hero, AppComponent, HEROES; return { setters:[ function (core_1_1) { core_1 = core_1_1; }], execute: function() { + Hero = (function () { + function Hero() { + } + return Hero; + }()); + exports_1("Hero", Hero); AppComponent = (function () { function AppComponent() { this.title = 'Tour of Heroes'; - this.hero = { - id: 1, - name: 'Windstorm' - }; + this.heroes = HEROES; } + AppComponent.prototype.onSelect = function (hero) { this.selectedHero = hero; }; AppComponent = __decorate([ core_1.Component({ selector: 'my-app', - template: "\n

{{title}}

\n

{{hero.name}} details!

\n
{{hero.id}}
\n
\n \n \n
\n " + template: "\n

{{title}}

\n

My Heroes

\n
    \n
  • \n {{hero.id}} {{hero.name}}\n
  • \n
\n
\n

{{selectedHero.name}} details!

\n
{{selectedHero.id}}
\n
\n \n \n
\n
\n ", + styles: ["\n .selected {\n background-color: #CFD8DC !important;\n color: white;\n }\n .heroes {\n margin: 0 0 2em 0;\n list-style-type: none;\n padding: 0;\n width: 15em;\n }\n .heroes li {\n cursor: pointer;\n position: relative;\n left: 0;\n background-color: #EEE;\n margin: .5em;\n padding: .3em 0;\n height: 1.6em;\n border-radius: 4px;\n }\n .heroes li.selected:hover {\n background-color: #BBD8DC !important;\n color: white;\n }\n .heroes li:hover {\n color: #607D8B;\n background-color: #DDD;\n left: .1em;\n }\n .heroes .text {\n position: relative;\n top: -3px;\n }\n .heroes .badge {\n display: inline-block;\n font-size: small;\n color: white;\n padding: 0.8em 0.7em 0 0.7em;\n background-color: #607D8B;\n line-height: 1em;\n position: relative;\n left: -1px;\n top: -4px;\n height: 1.8em;\n margin-right: .8em;\n border-radius: 4px 0 0 4px;\n }\n "] }), __metadata('design:paramtypes', []) ], AppComponent); return AppComponent; }()); exports_1("AppComponent", AppComponent); + HEROES = [ + { "id": 11, "name": "Mr. Nice" }, + { "id": 12, "name": "Narco" }, + { "id": 13, "name": "Bombasto" }, + { "id": 14, "name": "Celeritas" }, + { "id": 15, "name": "Magneta" }, + { "id": 16, "name": "RubberMan" }, + { "id": 17, "name": "Dynama" }, + { "id": 18, "name": "Dr IQ" }, + { "id": 19, "name": "Magma" }, + { "id": 20, "name": "Tornado" } + ]; } } }); diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map index 2f1820b..416cc8d 100644 --- a/Angular2-quickstart/app/app.component.js.map +++ b/Angular2-quickstart/app/app.component.js.map @@ -1 +1 @@ -{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAqBA;gBAAA;oBACS,UAAK,GAAG,gBAAgB,CAAC;oBACzB,SAAI,GAAS;wBAChB,EAAE,EAAE,CAAC;wBACL,IAAI,EAAE,WAAW;qBAClB,CAAC;gBACN,CAAC;gBAnBD;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,sPAQN;qBAEN,CAAC;;gCAAA;gBAOF,mBAAC;YAAD,CAAC,AAND,IAMC;YAND,uCAMC,CAAA"} \ No newline at end of file +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;4BAkFI,MAAM;;;;;;;YAjFV;gBAAA;gBAGA,CAAC;gBAAD,WAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uBAGC,CAAA;YAwED;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;oBACzB,WAAM,GAAG,MAAM,CAAC;gBAGlB,CAAC;gBADC,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBA3EpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,ikBAkBR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;qBACH,CAAC;;gCAAA;gBAMF,mBAAC;YAAD,CAAC,AALD,IAKC;YALD,uCAKC,CAAA;YACG,MAAM,GAAW;gBACnB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;gBAC/B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;gBAC9B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;aAChC,CAAC"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts index bd70f05..8f3b24c 100644 --- a/Angular2-quickstart/app/app.component.ts +++ b/Angular2-quickstart/app/app.component.ts @@ -1,28 +1,94 @@ import {Component} from 'angular2/core'; - -interface Hero { +export class Hero { id: number; name: string; } - - @Component({ - selector: 'my-app', - template:` -

{{title}}

-

{{hero.name}} details!

-
{{hero.id}}
+ selector: 'my-app', + template:` +

{{title}}

+

My Heroes

+
    +
  • + {{hero.id}} {{hero.name}} +
  • +
+
+

{{selectedHero.name}} details!

+
{{selectedHero.id}}
- +
- ` - +
+ `, + styles:[` + .selected { + background-color: #CFD8DC !important; + color: white; + } + .heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; + } + .heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; + } + .heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; + } + .heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; + } + .heroes .text { + position: relative; + top: -3px; + } + .heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; + } + `] }) export class AppComponent { - public title = 'Tour of Heroes'; - public hero: Hero = { - id: 1, - name: 'Windstorm' - }; + title = 'Tour of Heroes'; + heroes = HEROES; + selectedHero: Hero; + onSelect(hero: Hero) { this.selectedHero = hero; } } +var HEROES: Hero[] = [ + { "id": 11, "name": "Mr. Nice" }, + { "id": 12, "name": "Narco" }, + { "id": 13, "name": "Bombasto" }, + { "id": 14, "name": "Celeritas" }, + { "id": 15, "name": "Magneta" }, + { "id": 16, "name": "RubberMan" }, + { "id": 17, "name": "Dynama" }, + { "id": 18, "name": "Dr IQ" }, + { "id": 19, "name": "Magma" }, + { "id": 20, "name": "Tornado" } +]; From 314439587992c0bde75a0e1ecee154db1938326a Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Mon, 28 Mar 2016 06:46:06 -0600 Subject: [PATCH 4/7] MULTIPLE COMPONENTS --- Angular2-quickstart/app/app.component.js | 20 ++++----- Angular2-quickstart/app/app.component.js.map | 2 +- Angular2-quickstart/app/app.component.ts | 18 +++----- .../app/hero-detail.component.js | 44 +++++++++++++++++++ .../app/hero-detail.component.js.map | 1 + .../app/hero-detail.component.ts | 19 ++++++++ Angular2-quickstart/app/hero.js | 17 +++++++ Angular2-quickstart/app/hero.js.map | 1 + Angular2-quickstart/app/hero.ts | 4 ++ 9 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 Angular2-quickstart/app/hero-detail.component.js create mode 100644 Angular2-quickstart/app/hero-detail.component.js.map create mode 100644 Angular2-quickstart/app/hero-detail.component.ts create mode 100644 Angular2-quickstart/app/hero.js create mode 100644 Angular2-quickstart/app/hero.js.map create mode 100644 Angular2-quickstart/app/hero.ts diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js index 9378ab4..88a236e 100644 --- a/Angular2-quickstart/app/app.component.js +++ b/Angular2-quickstart/app/app.component.js @@ -1,4 +1,4 @@ -System.register(['angular2/core'], function(exports_1, context_1) { +System.register(['angular2/core', './hero-detail.component'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -10,20 +10,17 @@ System.register(['angular2/core'], function(exports_1, context_1) { var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; - var core_1; - var Hero, AppComponent, HEROES; + var core_1, hero_detail_component_1; + var AppComponent, HEROES; return { setters:[ function (core_1_1) { core_1 = core_1_1; + }, + function (hero_detail_component_1_1) { + hero_detail_component_1 = hero_detail_component_1_1; }], execute: function() { - Hero = (function () { - function Hero() { - } - return Hero; - }()); - exports_1("Hero", Hero); AppComponent = (function () { function AppComponent() { this.title = 'Tour of Heroes'; @@ -33,8 +30,9 @@ System.register(['angular2/core'], function(exports_1, context_1) { AppComponent = __decorate([ core_1.Component({ selector: 'my-app', - template: "\n

{{title}}

\n

My Heroes

\n
    \n
  • \n {{hero.id}} {{hero.name}}\n
  • \n
\n
\n

{{selectedHero.name}} details!

\n
{{selectedHero.id}}
\n
\n \n \n
\n
\n ", - styles: ["\n .selected {\n background-color: #CFD8DC !important;\n color: white;\n }\n .heroes {\n margin: 0 0 2em 0;\n list-style-type: none;\n padding: 0;\n width: 15em;\n }\n .heroes li {\n cursor: pointer;\n position: relative;\n left: 0;\n background-color: #EEE;\n margin: .5em;\n padding: .3em 0;\n height: 1.6em;\n border-radius: 4px;\n }\n .heroes li.selected:hover {\n background-color: #BBD8DC !important;\n color: white;\n }\n .heroes li:hover {\n color: #607D8B;\n background-color: #DDD;\n left: .1em;\n }\n .heroes .text {\n position: relative;\n top: -3px;\n }\n .heroes .badge {\n display: inline-block;\n font-size: small;\n color: white;\n padding: 0.8em 0.7em 0 0.7em;\n background-color: #607D8B;\n line-height: 1em;\n position: relative;\n left: -1px;\n top: -4px;\n height: 1.8em;\n margin-right: .8em;\n border-radius: 4px 0 0 4px;\n }\n "] + template: "\n

{{title}}

\n

My Heroes

\n
    \n
  • \n {{hero.id}} {{hero.name}}\n
  • \n
\n \n ", + styles: ["\n .selected {\n background-color: #CFD8DC !important;\n color: white;\n }\n .heroes {\n margin: 0 0 2em 0;\n list-style-type: none;\n padding: 0;\n width: 15em;\n }\n .heroes li {\n cursor: pointer;\n position: relative;\n left: 0;\n background-color: #EEE;\n margin: .5em;\n padding: .3em 0;\n height: 1.6em;\n border-radius: 4px;\n }\n .heroes li.selected:hover {\n background-color: #BBD8DC !important;\n color: white;\n }\n .heroes li:hover {\n color: #607D8B;\n background-color: #DDD;\n left: .1em;\n }\n .heroes .text {\n position: relative;\n top: -3px;\n }\n .heroes .badge {\n display: inline-block;\n font-size: small;\n color: white;\n padding: 0.8em 0.7em 0 0.7em;\n background-color: #607D8B;\n line-height: 1em;\n position: relative;\n left: -1px;\n top: -4px;\n height: 1.8em;\n margin-right: .8em;\n border-radius: 4px 0 0 4px;\n }\n "], + directives: [hero_detail_component_1.HeroDetailComponent] }), __metadata('design:paramtypes', []) ], AppComponent); diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map index 416cc8d..86940a6 100644 --- a/Angular2-quickstart/app/app.component.js.map +++ b/Angular2-quickstart/app/app.component.js.map @@ -1 +1 @@ -{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;4BAkFI,MAAM;;;;;;;YAjFV;gBAAA;gBAGA,CAAC;gBAAD,WAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uBAGC,CAAA;YAwED;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;oBACzB,WAAM,GAAG,MAAM,CAAC;gBAGlB,CAAC;gBADC,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBA3EpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,ikBAkBR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;qBACH,CAAC;;gCAAA;gBAMF,mBAAC;YAAD,CAAC,AALD,IAKC;YALD,uCAKC,CAAA;YACG,MAAM,GAAW;gBACnB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;gBAC/B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;gBAC9B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;aAChC,CAAC"} \ No newline at end of file +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;sBA0EI,MAAM;;;;;;;;;;YANV;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;oBACzB,WAAM,GAAG,MAAM,CAAC;gBAGlB,CAAC;gBADC,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBArEpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,uWAWR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;wBACF,UAAU,EAAE,CAAC,2CAAmB,CAAC;qBAClC,CAAC;;gCAAA;gBAMF,mBAAC;YAAD,CAAC,AALD,IAKC;YALD,uCAKC,CAAA;YACG,MAAM,GAAW;gBACnB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;gBAC/B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;gBAC9B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;aAChC,CAAC"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts index 8f3b24c..f27cbce 100644 --- a/Angular2-quickstart/app/app.component.ts +++ b/Angular2-quickstart/app/app.component.ts @@ -1,8 +1,6 @@ import {Component} from 'angular2/core'; -export class Hero { - id: number; - name: string; -} +import {Hero} from './hero'; +import {HeroDetailComponent} from './hero-detail.component'; @Component({ selector: 'my-app', template:` @@ -15,14 +13,7 @@ export class Hero { {{hero.id}} {{hero.name}} -
-

{{selectedHero.name}} details!

-
{{selectedHero.id}}
-
- - -
-
+ `, styles:[` .selected { @@ -72,7 +63,8 @@ export class Hero { margin-right: .8em; border-radius: 4px 0 0 4px; } - `] + `], + directives: [HeroDetailComponent] }) export class AppComponent { title = 'Tour of Heroes'; diff --git a/Angular2-quickstart/app/hero-detail.component.js b/Angular2-quickstart/app/hero-detail.component.js new file mode 100644 index 0000000..ead5f31 --- /dev/null +++ b/Angular2-quickstart/app/hero-detail.component.js @@ -0,0 +1,44 @@ +System.register(['angular2/core', './hero'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1, hero_1; + var HeroDetailComponent; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }, + function (hero_1_1) { + hero_1 = hero_1_1; + }], + execute: function() { + HeroDetailComponent = (function () { + function HeroDetailComponent() { + } + __decorate([ + core_1.Input(), + __metadata('design:type', hero_1.Hero) + ], HeroDetailComponent.prototype, "hero", void 0); + HeroDetailComponent = __decorate([ + core_1.Component({ + selector: 'my-hero-detail', + template: "\n
\n

{{hero.name}} details!

\n
{{hero.id}}
\n
\n \n \n
\n
\n " + }), + __metadata('design:paramtypes', []) + ], HeroDetailComponent); + return HeroDetailComponent; + }()); + exports_1("HeroDetailComponent", HeroDetailComponent); + } + } +}); +//# sourceMappingURL=hero-detail.component.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/hero-detail.component.js.map b/Angular2-quickstart/app/hero-detail.component.js.map new file mode 100644 index 0000000..60a3731 --- /dev/null +++ b/Angular2-quickstart/app/hero-detail.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero-detail.component.js","sourceRoot":"","sources":["hero-detail.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAeA;gBAAA;gBAGA,CAAC;gBAFC;oBAAC,YAAK,EAAE;;iEAAA;gBAdV;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,+PAST;qBACF,CAAC;;uCAAA;gBAIF,0BAAC;YAAD,CAAC,AAHD,IAGC;YAHD,qDAGC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero-detail.component.ts b/Angular2-quickstart/app/hero-detail.component.ts new file mode 100644 index 0000000..45674be --- /dev/null +++ b/Angular2-quickstart/app/hero-detail.component.ts @@ -0,0 +1,19 @@ +import {Component, Input} from 'angular2/core'; +import {Hero} from './hero'; +@Component({ + selector: 'my-hero-detail', + template: ` +
+

{{hero.name}} details!

+
{{hero.id}}
+
+ + +
+
+ ` +}) +export class HeroDetailComponent { + @Input() + hero: Hero; +} diff --git a/Angular2-quickstart/app/hero.js b/Angular2-quickstart/app/hero.js new file mode 100644 index 0000000..ef515b0 --- /dev/null +++ b/Angular2-quickstart/app/hero.js @@ -0,0 +1,17 @@ +System.register([], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var Hero; + return { + setters:[], + execute: function() { + Hero = (function () { + function Hero() { + } + return Hero; + }()); + exports_1("Hero", Hero); + } + } +}); +//# sourceMappingURL=hero.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.js.map b/Angular2-quickstart/app/hero.js.map new file mode 100644 index 0000000..ce8c2af --- /dev/null +++ b/Angular2-quickstart/app/hero.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero.js","sourceRoot":"","sources":["hero.ts"],"names":[],"mappings":";;;;;;;YAAA;gBAAA;gBAGA,CAAC;gBAAD,WAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uBAGC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.ts b/Angular2-quickstart/app/hero.ts new file mode 100644 index 0000000..e3eac51 --- /dev/null +++ b/Angular2-quickstart/app/hero.ts @@ -0,0 +1,4 @@ +export class Hero { + id: number; + name: string; +} From d28928165e384681c682446b968bfec1f6d36d52 Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Mon, 28 Mar 2016 07:12:21 -0600 Subject: [PATCH 5/7] SERVICES --- Angular2-quickstart/app/app.component.js | 37 ++++++++------- Angular2-quickstart/app/app.component.js.map | 2 +- Angular2-quickstart/app/app.component.ts | 29 ++++++------ Angular2-quickstart/app/hero.service.js | 48 ++++++++++++++++++++ Angular2-quickstart/app/hero.service.js.map | 1 + Angular2-quickstart/app/hero.service.ts | 15 ++++++ Angular2-quickstart/app/mock-heroes.js | 23 ++++++++++ Angular2-quickstart/app/mock-heroes.js.map | 1 + Angular2-quickstart/app/mock-heroes.ts | 13 ++++++ 9 files changed, 133 insertions(+), 36 deletions(-) create mode 100644 Angular2-quickstart/app/hero.service.js create mode 100644 Angular2-quickstart/app/hero.service.js.map create mode 100644 Angular2-quickstart/app/hero.service.ts create mode 100644 Angular2-quickstart/app/mock-heroes.js create mode 100644 Angular2-quickstart/app/mock-heroes.js.map create mode 100644 Angular2-quickstart/app/mock-heroes.ts diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js index 88a236e..c780502 100644 --- a/Angular2-quickstart/app/app.component.js +++ b/Angular2-quickstart/app/app.component.js @@ -1,4 +1,4 @@ -System.register(['angular2/core', './hero-detail.component'], function(exports_1, context_1) { +System.register(['angular2/core', './hero-detail.component', './hero.service'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -10,8 +10,8 @@ System.register(['angular2/core', './hero-detail.component'], function(exports_1 var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; - var core_1, hero_detail_component_1; - var AppComponent, HEROES; + var core_1, hero_detail_component_1, hero_service_1; + var AppComponent; return { setters:[ function (core_1_1) { @@ -19,38 +19,37 @@ System.register(['angular2/core', './hero-detail.component'], function(exports_1 }, function (hero_detail_component_1_1) { hero_detail_component_1 = hero_detail_component_1_1; + }, + function (hero_service_1_1) { + hero_service_1 = hero_service_1_1; }], execute: function() { AppComponent = (function () { - function AppComponent() { + function AppComponent(_heroService) { + this._heroService = _heroService; this.title = 'Tour of Heroes'; - this.heroes = HEROES; } + AppComponent.prototype.getHeroes = function () { + var _this = this; + this._heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes; }); + }; + AppComponent.prototype.ngOnInit = function () { + this.getHeroes(); + }; AppComponent.prototype.onSelect = function (hero) { this.selectedHero = hero; }; AppComponent = __decorate([ core_1.Component({ selector: 'my-app', template: "\n

{{title}}

\n

My Heroes

\n
    \n
  • \n {{hero.id}} {{hero.name}}\n
  • \n
\n \n ", styles: ["\n .selected {\n background-color: #CFD8DC !important;\n color: white;\n }\n .heroes {\n margin: 0 0 2em 0;\n list-style-type: none;\n padding: 0;\n width: 15em;\n }\n .heroes li {\n cursor: pointer;\n position: relative;\n left: 0;\n background-color: #EEE;\n margin: .5em;\n padding: .3em 0;\n height: 1.6em;\n border-radius: 4px;\n }\n .heroes li.selected:hover {\n background-color: #BBD8DC !important;\n color: white;\n }\n .heroes li:hover {\n color: #607D8B;\n background-color: #DDD;\n left: .1em;\n }\n .heroes .text {\n position: relative;\n top: -3px;\n }\n .heroes .badge {\n display: inline-block;\n font-size: small;\n color: white;\n padding: 0.8em 0.7em 0 0.7em;\n background-color: #607D8B;\n line-height: 1em;\n position: relative;\n left: -1px;\n top: -4px;\n height: 1.8em;\n margin-right: .8em;\n border-radius: 4px 0 0 4px;\n }\n "], - directives: [hero_detail_component_1.HeroDetailComponent] + directives: [hero_detail_component_1.HeroDetailComponent], + providers: [hero_service_1.HeroService] }), - __metadata('design:paramtypes', []) + __metadata('design:paramtypes', [hero_service_1.HeroService]) ], AppComponent); return AppComponent; }()); exports_1("AppComponent", AppComponent); - HEROES = [ - { "id": 11, "name": "Mr. Nice" }, - { "id": 12, "name": "Narco" }, - { "id": 13, "name": "Bombasto" }, - { "id": 14, "name": "Celeritas" }, - { "id": 15, "name": "Magneta" }, - { "id": 16, "name": "RubberMan" }, - { "id": 17, "name": "Dynama" }, - { "id": 18, "name": "Dr IQ" }, - { "id": 19, "name": "Magma" }, - { "id": 20, "name": "Tornado" } - ]; } } }); diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map index 86940a6..ec617db 100644 --- a/Angular2-quickstart/app/app.component.js.map +++ b/Angular2-quickstart/app/app.component.js.map @@ -1 +1 @@ -{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;sBA0EI,MAAM;;;;;;;;;;YANV;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;oBACzB,WAAM,GAAG,MAAM,CAAC;gBAGlB,CAAC;gBADC,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBArEpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,uWAWR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;wBACF,UAAU,EAAE,CAAC,2CAAmB,CAAC;qBAClC,CAAC;;gCAAA;gBAMF,mBAAC;YAAD,CAAC,AALD,IAKC;YALD,uCAKC,CAAA;YACG,MAAM,GAAW;gBACnB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAChC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;gBAC/B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBACjC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;gBAC9B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;gBAC7B,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;aAChC,CAAC"} \ No newline at end of file +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAsEA;gBAIE,sBAAoB,YAAyB;oBAAzB,iBAAY,GAAZ,YAAY,CAAa;oBAH7C,UAAK,GAAG,gBAAgB,CAAC;gBAGwB,CAAC;gBAClD,gCAAS,GAAT;oBAAA,iBAEC;oBADC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,EAApB,CAAoB,CAAC,CAAC;gBACrE,CAAC;gBACD,+BAAQ,GAAR;oBACE,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,CAAC;gBACD,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBA7EpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,uWAWR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;wBACF,UAAU,EAAE,CAAC,2CAAmB,CAAC;wBACjC,SAAS,EAAE,CAAC,0BAAW,CAAC;qBACzB,CAAC;;gCAAA;gBAaF,mBAAC;YAAD,CAAC,AAZD,IAYC;YAZD,uCAYC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts index f27cbce..c7bd72b 100644 --- a/Angular2-quickstart/app/app.component.ts +++ b/Angular2-quickstart/app/app.component.ts @@ -1,6 +1,7 @@ -import {Component} from 'angular2/core'; +import {Component, OnInit} from 'angular2/core'; import {Hero} from './hero'; import {HeroDetailComponent} from './hero-detail.component'; +import {HeroService} from './hero.service'; @Component({ selector: 'my-app', template:` @@ -64,23 +65,19 @@ import {HeroDetailComponent} from './hero-detail.component'; border-radius: 4px 0 0 4px; } `], - directives: [HeroDetailComponent] + directives: [HeroDetailComponent], + providers: [HeroService] }) -export class AppComponent { +export class AppComponent implements OnInit { title = 'Tour of Heroes'; - heroes = HEROES; + heroes: Hero[]; selectedHero: Hero; + constructor(private _heroService: HeroService) { } + getHeroes() { + this._heroService.getHeroes().then(heroes => this.heroes = heroes); + } + ngOnInit() { + this.getHeroes(); + } onSelect(hero: Hero) { this.selectedHero = hero; } } -var HEROES: Hero[] = [ - { "id": 11, "name": "Mr. Nice" }, - { "id": 12, "name": "Narco" }, - { "id": 13, "name": "Bombasto" }, - { "id": 14, "name": "Celeritas" }, - { "id": 15, "name": "Magneta" }, - { "id": 16, "name": "RubberMan" }, - { "id": 17, "name": "Dynama" }, - { "id": 18, "name": "Dr IQ" }, - { "id": 19, "name": "Magma" }, - { "id": 20, "name": "Tornado" } -]; diff --git a/Angular2-quickstart/app/hero.service.js b/Angular2-quickstart/app/hero.service.js new file mode 100644 index 0000000..d989b78 --- /dev/null +++ b/Angular2-quickstart/app/hero.service.js @@ -0,0 +1,48 @@ +System.register(['angular2/core', './mock-heroes'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1, mock_heroes_1; + var HeroService; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }, + function (mock_heroes_1_1) { + mock_heroes_1 = mock_heroes_1_1; + }], + execute: function() { + HeroService = (function () { + function HeroService() { + } + HeroService.prototype.getHeroes = function () { + return Promise.resolve(mock_heroes_1.HEROES); + }; + // See the "Take it slow" appendix + HeroService.prototype.getHeroesSlowly = function () { + return new Promise(function (resolve) { + return setTimeout(function () { return resolve(mock_heroes_1.HEROES); }, 2000); + } // 2 seconds + // 2 seconds + ); + }; + HeroService = __decorate([ + core_1.Injectable(), + __metadata('design:paramtypes', []) + ], HeroService); + return HeroService; + }()); + exports_1("HeroService", HeroService); + } + } +}); +//# sourceMappingURL=hero.service.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.service.js.map b/Angular2-quickstart/app/hero.service.js.map new file mode 100644 index 0000000..09bb34d --- /dev/null +++ b/Angular2-quickstart/app/hero.service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero.service.js","sourceRoot":"","sources":["hero.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAIA;gBAAA;gBAUA,CAAC;gBATC,+BAAS,GAAT;oBACE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC;gBACjC,CAAC;gBACD,kCAAkC;gBAClC,qCAAe,GAAf;oBACE,MAAM,CAAC,IAAI,OAAO,CAAS,UAAA,OAAO;wBAChC,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,CAAC,oBAAM,CAAC,EAAf,CAAe,EAAE,IAAI,CAAC;oBAArC,CAAqC,CAAC,YAAY;oBAAb,CAAC,YAAY;qBACnD,CAAC;gBACJ,CAAC;gBAVH;oBAAC,iBAAU,EAAE;;+BAAA;gBAWb,kBAAC;YAAD,CAAC,AAVD,IAUC;YAVD,qCAUC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.service.ts b/Angular2-quickstart/app/hero.service.ts new file mode 100644 index 0000000..8185262 --- /dev/null +++ b/Angular2-quickstart/app/hero.service.ts @@ -0,0 +1,15 @@ +import {Injectable} from 'angular2/core'; +import {Hero} from './hero'; +import {HEROES} from './mock-heroes'; +@Injectable() +export class HeroService { + getHeroes() { + return Promise.resolve(HEROES); + } + // See the "Take it slow" appendix + getHeroesSlowly() { + return new Promise(resolve => + setTimeout(()=>resolve(HEROES), 2000) // 2 seconds + ); + } +} diff --git a/Angular2-quickstart/app/mock-heroes.js b/Angular2-quickstart/app/mock-heroes.js new file mode 100644 index 0000000..9aa4043 --- /dev/null +++ b/Angular2-quickstart/app/mock-heroes.js @@ -0,0 +1,23 @@ +System.register([], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var HEROES; + return { + setters:[], + execute: function() { + exports_1("HEROES", HEROES = [ + { "id": 11, "name": "Mr. Nice" }, + { "id": 12, "name": "Narco" }, + { "id": 13, "name": "Bombasto" }, + { "id": 14, "name": "Celeritas" }, + { "id": 15, "name": "Magneta" }, + { "id": 16, "name": "RubberMan" }, + { "id": 17, "name": "Dynama" }, + { "id": 18, "name": "Dr IQ" }, + { "id": 19, "name": "Magma" }, + { "id": 20, "name": "Tornado" } + ]); + } + } +}); +//# sourceMappingURL=mock-heroes.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/mock-heroes.js.map b/Angular2-quickstart/app/mock-heroes.js.map new file mode 100644 index 0000000..70ebf29 --- /dev/null +++ b/Angular2-quickstart/app/mock-heroes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mock-heroes.js","sourceRoot":"","sources":["mock-heroes.ts"],"names":[],"mappings":";;;QACW,MAAM;;;;YAAN,oBAAA,MAAM,GAAW;gBACxB,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAC;gBAC9B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;gBAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAC;gBAC9B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAC;gBAC/B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC;gBAC7B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAC;gBAC/B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAC;gBAC5B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;gBAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;gBAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC;aAChC,CAAA,CAAC"} \ No newline at end of file diff --git a/Angular2-quickstart/app/mock-heroes.ts b/Angular2-quickstart/app/mock-heroes.ts new file mode 100644 index 0000000..a5cb381 --- /dev/null +++ b/Angular2-quickstart/app/mock-heroes.ts @@ -0,0 +1,13 @@ +import {Hero} from './hero'; +export var HEROES: Hero[] = [ + {"id": 11, "name": "Mr. Nice"}, + {"id": 12, "name": "Narco"}, + {"id": 13, "name": "Bombasto"}, + {"id": 14, "name": "Celeritas"}, + {"id": 15, "name": "Magneta"}, + {"id": 16, "name": "RubberMan"}, + {"id": 17, "name": "Dynama"}, + {"id": 18, "name": "Dr IQ"}, + {"id": 19, "name": "Magma"}, + {"id": 20, "name": "Tornado"} +]; From 1502f9ca20ac7487ca2aa3150421814c4b665ed2 Mon Sep 17 00:00:00 2001 From: Dustin Robertson Date: Mon, 28 Mar 2016 09:03:00 -0600 Subject: [PATCH 6/7] ROUTING --- Angular2-quickstart/app/app.component.css | 28 +++++ Angular2-quickstart/app/app.component.js | 48 ++++---- Angular2-quickstart/app/app.component.js.map | 2 +- Angular2-quickstart/app/app.component.ts | 107 +++++------------- .../app/dashboard.component.css | 60 ++++++++++ .../app/dashboard.component.html | 8 ++ .../app/dashboard.component.js | 55 +++++++++ .../app/dashboard.component.js.map | 1 + .../app/dashboard.component.ts | 30 +++++ .../app/hero-detail.component.css | 29 +++++ .../app/hero-detail.component.html | 10 ++ .../app/hero-detail.component.js | 28 ++++- .../app/hero-detail.component.js.map | 2 +- .../app/hero-detail.component.ts | 42 ++++--- Angular2-quickstart/app/hero.service.js | 4 + Angular2-quickstart/app/hero.service.js.map | 2 +- Angular2-quickstart/app/hero.service.ts | 7 ++ Angular2-quickstart/app/heroes.component.css | 47 ++++++++ Angular2-quickstart/app/heroes.component.html | 15 +++ Angular2-quickstart/app/heroes.component.js | 58 ++++++++++ .../app/heroes.component.js.map | 1 + Angular2-quickstart/app/heroes.component.ts | 30 +++++ Angular2-quickstart/index.html | 4 + Angular2-quickstart/styles.css | 33 ++++++ 24 files changed, 529 insertions(+), 122 deletions(-) create mode 100644 Angular2-quickstart/app/app.component.css create mode 100644 Angular2-quickstart/app/dashboard.component.css create mode 100644 Angular2-quickstart/app/dashboard.component.html create mode 100644 Angular2-quickstart/app/dashboard.component.js create mode 100644 Angular2-quickstart/app/dashboard.component.js.map create mode 100644 Angular2-quickstart/app/dashboard.component.ts create mode 100644 Angular2-quickstart/app/hero-detail.component.css create mode 100644 Angular2-quickstart/app/hero-detail.component.html create mode 100644 Angular2-quickstart/app/heroes.component.css create mode 100644 Angular2-quickstart/app/heroes.component.html create mode 100644 Angular2-quickstart/app/heroes.component.js create mode 100644 Angular2-quickstart/app/heroes.component.js.map create mode 100644 Angular2-quickstart/app/heroes.component.ts create mode 100644 Angular2-quickstart/styles.css diff --git a/Angular2-quickstart/app/app.component.css b/Angular2-quickstart/app/app.component.css new file mode 100644 index 0000000..b71b158 --- /dev/null +++ b/Angular2-quickstart/app/app.component.css @@ -0,0 +1,28 @@ +h1 { + font-size: 1.2em; + color: #999; + margin-bottom: 0; +} +h2 { + font-size: 2em; + margin-top: 0; + padding-top: 0; +} +nav a { + padding: 5px 10px; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #eee; + border-radius: 4px; +} +nav a:visited, a:link { + color: #607D8B; +} +nav a:hover { + color: #039be5; + background-color: #CFD8DC; +} +nav a.router-link-active { + color: #039be5; +} diff --git a/Angular2-quickstart/app/app.component.js b/Angular2-quickstart/app/app.component.js index c780502..ae46f75 100644 --- a/Angular2-quickstart/app/app.component.js +++ b/Angular2-quickstart/app/app.component.js @@ -1,4 +1,4 @@ -System.register(['angular2/core', './hero-detail.component', './hero.service'], function(exports_1, context_1) { +System.register(['angular2/core', 'angular2/router', './hero.service', './heroes.component', './hero-detail.component'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -10,42 +10,50 @@ System.register(['angular2/core', './hero-detail.component', './hero.service'], var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; - var core_1, hero_detail_component_1, hero_service_1; + var core_1, router_1, hero_service_1, heroes_component_1, hero_detail_component_1; var AppComponent; return { setters:[ function (core_1_1) { core_1 = core_1_1; }, - function (hero_detail_component_1_1) { - hero_detail_component_1 = hero_detail_component_1_1; + function (router_1_1) { + router_1 = router_1_1; }, function (hero_service_1_1) { hero_service_1 = hero_service_1_1; + }, + function (heroes_component_1_1) { + heroes_component_1 = heroes_component_1_1; + }, + function (hero_detail_component_1_1) { + hero_detail_component_1 = hero_detail_component_1_1; }], execute: function() { AppComponent = (function () { - function AppComponent(_heroService) { - this._heroService = _heroService; + function AppComponent() { this.title = 'Tour of Heroes'; } - AppComponent.prototype.getHeroes = function () { - var _this = this; - this._heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes; }); - }; - AppComponent.prototype.ngOnInit = function () { - this.getHeroes(); - }; - AppComponent.prototype.onSelect = function (hero) { this.selectedHero = hero; }; AppComponent = __decorate([ core_1.Component({ selector: 'my-app', - template: "\n

{{title}}

\n

My Heroes

\n
    \n
  • \n {{hero.id}} {{hero.name}}\n
  • \n
\n \n ", - styles: ["\n .selected {\n background-color: #CFD8DC !important;\n color: white;\n }\n .heroes {\n margin: 0 0 2em 0;\n list-style-type: none;\n padding: 0;\n width: 15em;\n }\n .heroes li {\n cursor: pointer;\n position: relative;\n left: 0;\n background-color: #EEE;\n margin: .5em;\n padding: .3em 0;\n height: 1.6em;\n border-radius: 4px;\n }\n .heroes li.selected:hover {\n background-color: #BBD8DC !important;\n color: white;\n }\n .heroes li:hover {\n color: #607D8B;\n background-color: #DDD;\n left: .1em;\n }\n .heroes .text {\n position: relative;\n top: -3px;\n }\n .heroes .badge {\n display: inline-block;\n font-size: small;\n color: white;\n padding: 0.8em 0.7em 0 0.7em;\n background-color: #607D8B;\n line-height: 1em;\n position: relative;\n left: -1px;\n top: -4px;\n height: 1.8em;\n margin-right: .8em;\n border-radius: 4px 0 0 4px;\n }\n "], - directives: [hero_detail_component_1.HeroDetailComponent], - providers: [hero_service_1.HeroService] - }), - __metadata('design:paramtypes', [hero_service_1.HeroService]) + template: "\n

{{title}}

\n
\n \n", + styleUrls: ['app/app.component.css'], + directives: [router_1.ROUTER_DIRECTIVES], + providers: [ + router_1.ROUTER_PROVIDERS, + hero_service_1.HeroService + ] + }), + router_1.RouteConfig([ + { + path: '/heroes', '/dashboard': , '/detail/:id': , + name: 'Heroes', 'Dashboard': , 'HeroDetail': , + component: heroes_component_1.HeroesComponent, DashboardComponent: DashboardComponent, HeroDetailComponent: hero_detail_component_1.HeroDetailComponent, + useAsDefault: true + } + ]), + __metadata('design:paramtypes', []) ], AppComponent); return AppComponent; }()); diff --git a/Angular2-quickstart/app/app.component.js.map b/Angular2-quickstart/app/app.component.js.map index ec617db..e312ad0 100644 --- a/Angular2-quickstart/app/app.component.js.map +++ b/Angular2-quickstart/app/app.component.js.map @@ -1 +1 @@ -{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAsEA;gBAIE,sBAAoB,YAAyB;oBAAzB,iBAAY,GAAZ,YAAY,CAAa;oBAH7C,UAAK,GAAG,gBAAgB,CAAC;gBAGwB,CAAC;gBAClD,gCAAS,GAAT;oBAAA,iBAEC;oBADC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,EAApB,CAAoB,CAAC,CAAC;gBACrE,CAAC;gBACD,+BAAQ,GAAR;oBACE,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,CAAC;gBACD,+BAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBA7EpD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAC,uWAWR;wBACD,MAAM,EAAC,CAAC,siCAgDP,CAAC;wBACF,UAAU,EAAE,CAAC,2CAAmB,CAAC;wBACjC,SAAS,EAAE,CAAC,0BAAW,CAAC;qBACzB,CAAC;;gCAAA;gBAaF,mBAAC;YAAD,CAAC,AAZD,IAYC;YAZD,uCAYC,CAAA"} \ No newline at end of file +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+BA;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;gBAC3B,CAAC;gBA3BD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,oLAOX;wBACC,SAAS,EAAE,CAAC,uBAAuB,CAAC;wBACpC,UAAU,EAAE,CAAC,0BAAiB,CAAC;wBAC/B,SAAS,EAAE;4BACT,yBAAgB;4BAChB,0BAAW;yBACZ;qBACF,CAAC;oBACD,oBAAW,CAAC;wBACX;4BACE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAA,EAAE,aAAa,EAAA;4BAC5C,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAA,EAAE,YAAY,EAAA;4BACzC,SAAS,EAAE,kCAAe,EAAE,oBAAA,kBAAkB,EAAE,qBAAA,2CAAmB;4BACnE,YAAY,EAAE,IAAI;yBACnB;qBACF,CAAC;;gCAAA;gBAGF,mBAAC;YAAD,CAAC,AAFD,IAEC;YAFD,uCAEC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/app.component.ts b/Angular2-quickstart/app/app.component.ts index c7bd72b..4591990 100644 --- a/Angular2-quickstart/app/app.component.ts +++ b/Angular2-quickstart/app/app.component.ts @@ -1,83 +1,34 @@ -import {Component, OnInit} from 'angular2/core'; -import {Hero} from './hero'; -import {HeroDetailComponent} from './hero-detail.component'; -import {HeroService} from './hero.service'; +import { Component } from 'angular2/core'; +import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; +import { HeroService } from './hero.service'; +import { HeroesComponent } from './heroes.component'; +import { HeroDetailComponent } from './hero-detail.component'; + @Component({ selector: 'my-app', - template:` -

{{title}}

-

My Heroes

-
    -
  • - {{hero.id}} {{hero.name}} -
  • -
- - `, - styles:[` - .selected { - background-color: #CFD8DC !important; - color: white; - } - .heroes { - margin: 0 0 2em 0; - list-style-type: none; - padding: 0; - width: 15em; - } - .heroes li { - cursor: pointer; - position: relative; - left: 0; - background-color: #EEE; - margin: .5em; - padding: .3em 0; - height: 1.6em; - border-radius: 4px; - } - .heroes li.selected:hover { - background-color: #BBD8DC !important; - color: white; - } - .heroes li:hover { - color: #607D8B; - background-color: #DDD; - left: .1em; - } - .heroes .text { - position: relative; - top: -3px; - } - .heroes .badge { - display: inline-block; - font-size: small; - color: white; - padding: 0.8em 0.7em 0 0.7em; - background-color: #607D8B; - line-height: 1em; - position: relative; - left: -1px; - top: -4px; - height: 1.8em; - margin-right: .8em; - border-radius: 4px 0 0 4px; - } - `], - directives: [HeroDetailComponent], - providers: [HeroService] + template: ` +

{{title}}

+ + +`, + styleUrls: ['app/app.component.css'], + directives: [ROUTER_DIRECTIVES], + providers: [ + ROUTER_PROVIDERS, + HeroService + ] }) -export class AppComponent implements OnInit { - title = 'Tour of Heroes'; - heroes: Hero[]; - selectedHero: Hero; - constructor(private _heroService: HeroService) { } - getHeroes() { - this._heroService.getHeroes().then(heroes => this.heroes = heroes); - } - ngOnInit() { - this.getHeroes(); +@RouteConfig([ + { + path: '/heroes', '/dashboard', '/detail/:id', + name: 'Heroes', 'Dashboard', 'HeroDetail', + component: HeroesComponent, DashboardComponent, HeroDetailComponent, + useAsDefault: true } - onSelect(hero: Hero) { this.selectedHero = hero; } +]) +export class AppComponent { + title = 'Tour of Heroes'; } diff --git a/Angular2-quickstart/app/dashboard.component.css b/Angular2-quickstart/app/dashboard.component.css new file mode 100644 index 0000000..17d521f --- /dev/null +++ b/Angular2-quickstart/app/dashboard.component.css @@ -0,0 +1,60 @@ +[class*='col-'] { + float: left; +} +*, *:after, *:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +h3 { + text-align: center; margin-bottom: 0; +} +[class*='col-'] { + padding-right: 20px; + padding-bottom: 20px; +} +[class*='col-']:last-of-type { + padding-right: 0; +} +.grid { + margin: 0; +} +.col-1-4 { + width: 25%; +} +.module { + padding: 20px; + text-align: center; + color: #eee; + max-height: 120px; + min-width: 120px; + background-color: #607D8B; + border-radius: 2px; +} +h4 { + position: relative; +} +.module:hover { + background-color: #EEE; + cursor: pointer; + color: #607d8b; +} +.grid-pad { + padding: 10px 0; +} +.grid-pad > [class*='col-']:last-of-type { + padding-right: 20px; +} +@media (max-width: 600px) { + .module { + font-size: 10px; + max-height: 75px; } +} +@media (max-width: 1024px) { + .grid { + margin: 0; + } + .module { + min-width: 60px; + } +} diff --git a/Angular2-quickstart/app/dashboard.component.html b/Angular2-quickstart/app/dashboard.component.html new file mode 100644 index 0000000..6099f6b --- /dev/null +++ b/Angular2-quickstart/app/dashboard.component.html @@ -0,0 +1,8 @@ +

Top Heroes

+
+
+
+

{{hero.name}}

+
+
+
diff --git a/Angular2-quickstart/app/dashboard.component.js b/Angular2-quickstart/app/dashboard.component.js new file mode 100644 index 0000000..715db73 --- /dev/null +++ b/Angular2-quickstart/app/dashboard.component.js @@ -0,0 +1,55 @@ +System.register(['angular2/core'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1; + var DashboardComponent; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }], + execute: function() { + DashboardComponent = (function () { + function DashboardComponent() { + } + DashboardComponent = __decorate([ + core_1.Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'], + }), + __metadata('design:paramtypes', []) + ], DashboardComponent); + return DashboardComponent; + }()); + exports_1("DashboardComponent", DashboardComponent); + DashboardComponent = (function () { + function DashboardComponent(_heroService) { + this._heroService = _heroService; + this.heroes = []; + } + DashboardComponent.prototype.ngOnInit = function () { + var _this = this; + this._heroService.getHeroes() + .then(function (heroes) { return _this.heroes = heroes.slice(1, 5); }); + }; + DashboardComponent.prototype.gotoDetail = function (hero) { + var link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); + }; + return DashboardComponent; + }()); + exports_1("DashboardComponent", DashboardComponent); + } + } +}); +//# sourceMappingURL=dashboard.component.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/dashboard.component.js.map b/Angular2-quickstart/app/dashboard.component.js.map new file mode 100644 index 0000000..115e435 --- /dev/null +++ b/Angular2-quickstart/app/dashboard.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dashboard.component.js","sourceRoot":"","sources":["dashboard.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAWA;gBAAA;gBAAkC,CAAC;gBANnC;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,cAAc;wBACxB,WAAW,EAAE,8BAA8B;wBAC3C,SAAS,EAAE,CAAC,6BAA6B,CAAC;qBAE3C,CAAC;;sCAAA;gBACgC,yBAAC;YAAD,CAAC,AAAnC,IAAmC;YAAnC,mDAAmC,CAAA;YAEnC;gBAEE,4BAAoB,YAAyB;oBAAzB,iBAAY,GAAZ,YAAY,CAAa;oBAD7C,WAAM,GAAW,EAAE,CAAC;gBAC6B,CAAC;gBAClD,qCAAQ,GAAR;oBAAA,iBAGC;oBAFC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;yBAC1B,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,EAA/B,CAA+B,CAAC,CAAC;gBACrD,CAAC;gBACD,uCAAU,GAAV,UAAW,IAAU;oBACrB,IAAI,IAAI,GAAG,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC;gBAOD,yBAAC;YAAD,CAAC,AAjBD,IAeC;YAfD,mDAeC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/dashboard.component.ts b/Angular2-quickstart/app/dashboard.component.ts new file mode 100644 index 0000000..bc4bf2f --- /dev/null +++ b/Angular2-quickstart/app/dashboard.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from 'angular2/core'; +import { Router } from 'angular2/router'; +import { Hero } from './hero'; +import { HeroService } from './hero.service'; + +@Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'], + +}) +export class DashboardComponent { } + +export class DashboardComponent implements OnInit { + heroes: Hero[] = []; + constructor(private _heroService: HeroService) { } + ngOnInit() { + this._heroService.getHeroes() + .then(heroes => this.heroes = heroes.slice(1,5)); + } + gotoDetail(hero: Hero) { + let link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); +} + +constructor( + private _router: Router, + private _heroService: HeroService) { +} + diff --git a/Angular2-quickstart/app/hero-detail.component.css b/Angular2-quickstart/app/hero-detail.component.css new file mode 100644 index 0000000..b5ab6e6 --- /dev/null +++ b/Angular2-quickstart/app/hero-detail.component.css @@ -0,0 +1,29 @@ +label { + display: inline-block; + width: 3em; + margin: .5em 0; + color: #607D8B; + font-weight: bold; +} +input { + height: 2em; + font-size: 1em; + padding-left: .4em; +} +button { + margin-top: 20px; + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} +button:disabled { + background-color: #eee; + color: #ccc; + cursor: auto; +} diff --git a/Angular2-quickstart/app/hero-detail.component.html b/Angular2-quickstart/app/hero-detail.component.html new file mode 100644 index 0000000..6a78d67 --- /dev/null +++ b/Angular2-quickstart/app/hero-detail.component.html @@ -0,0 +1,10 @@ +
+

{{hero.name}} details!

+
+ {{hero.id}}
+
+ + +
+ +
diff --git a/Angular2-quickstart/app/hero-detail.component.js b/Angular2-quickstart/app/hero-detail.component.js index ead5f31..e447faa 100644 --- a/Angular2-quickstart/app/hero-detail.component.js +++ b/Angular2-quickstart/app/hero-detail.component.js @@ -1,4 +1,4 @@ -System.register(['angular2/core', './hero'], function(exports_1, context_1) { +System.register(['angular2/core', 'angular2/router', './hero', './hero.service'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -10,20 +10,37 @@ System.register(['angular2/core', './hero'], function(exports_1, context_1) { var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; - var core_1, hero_1; + var core_1, router_1, hero_1, hero_service_1; var HeroDetailComponent; return { setters:[ function (core_1_1) { core_1 = core_1_1; }, + function (router_1_1) { + router_1 = router_1_1; + }, function (hero_1_1) { hero_1 = hero_1_1; + }, + function (hero_service_1_1) { + hero_service_1 = hero_service_1_1; }], execute: function() { HeroDetailComponent = (function () { - function HeroDetailComponent() { + function HeroDetailComponent(_heroService, _routeParams) { + this._heroService = _heroService; + this._routeParams = _routeParams; } + HeroDetailComponent.prototype.ngOnInit = function () { + var _this = this; + var id = +this._routeParams.get('id'); + this._heroService.getHero(id) + .then(function (hero) { return _this.hero = hero; }); + }; + HeroDetailComponent.prototype.goBack = function () { + window.history.back(); + }; __decorate([ core_1.Input(), __metadata('design:type', hero_1.Hero) @@ -31,9 +48,10 @@ System.register(['angular2/core', './hero'], function(exports_1, context_1) { HeroDetailComponent = __decorate([ core_1.Component({ selector: 'my-hero-detail', - template: "\n
\n

{{hero.name}} details!

\n
{{hero.id}}
\n
\n \n \n
\n
\n " + templateUrl: 'app/hero-detail.component.html', + styleUrls: ['app/hero-detail.component.css'], }), - __metadata('design:paramtypes', []) + __metadata('design:paramtypes', [hero_service_1.HeroService, router_1.RouteParams]) ], HeroDetailComponent); return HeroDetailComponent; }()); diff --git a/Angular2-quickstart/app/hero-detail.component.js.map b/Angular2-quickstart/app/hero-detail.component.js.map index 60a3731..bd2896b 100644 --- a/Angular2-quickstart/app/hero-detail.component.js.map +++ b/Angular2-quickstart/app/hero-detail.component.js.map @@ -1 +1 @@ -{"version":3,"file":"hero-detail.component.js","sourceRoot":"","sources":["hero-detail.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAeA;gBAAA;gBAGA,CAAC;gBAFC;oBAAC,YAAK,EAAE;;iEAAA;gBAdV;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,+PAST;qBACF,CAAC;;uCAAA;gBAIF,0BAAC;YAAD,CAAC,AAHD,IAGC;YAHD,qDAGC,CAAA"} \ No newline at end of file +{"version":3,"file":"hero-detail.component.js","sourceRoot":"","sources":["hero-detail.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAWA;gBAGE,6BACU,YAAyB,EACzB,YAAyB;oBADzB,iBAAY,GAAZ,YAAY,CAAa;oBACzB,iBAAY,GAAZ,YAAY,CAAa;gBACnC,CAAC;gBAED,sCAAQ,GAAR;oBAAA,iBAIC;oBAHC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACtC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;yBAC1B,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,KAAI,CAAC,IAAI,GAAG,IAAI,EAAhB,CAAgB,CAAC,CAAC;gBACpC,CAAC;gBAED,oCAAM,GAAN;oBACE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACxB,CAAC;gBAfD;oBAAC,YAAK,EAAE;;iEAAA;gBANV;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,gBAAgB;wBAC1B,WAAW,EAAE,gCAAgC;wBAC7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;qBAC7C,CAAC;;uCAAA;gBAkBF,0BAAC;YAAD,CAAC,AAjBD,IAiBC;YAjBD,qDAiBC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero-detail.component.ts b/Angular2-quickstart/app/hero-detail.component.ts index 45674be..77ae4eb 100644 --- a/Angular2-quickstart/app/hero-detail.component.ts +++ b/Angular2-quickstart/app/hero-detail.component.ts @@ -1,19 +1,29 @@ -import {Component, Input} from 'angular2/core'; -import {Hero} from './hero'; +import { Component, Input, OnInit } from 'angular2/core'; +import { RouteParams } from 'angular2/router'; + +import { Hero } from './hero'; +import { HeroService } from './hero.service'; + @Component({ selector: 'my-hero-detail', - template: ` -
-

{{hero.name}} details!

-
{{hero.id}}
-
- - -
-
- ` + templateUrl: 'app/hero-detail.component.html', + styleUrls: ['app/hero-detail.component.css'], }) -export class HeroDetailComponent { - @Input() - hero: Hero; -} +export class HeroDetailComponent implements OnInit { + @Input() hero: Hero; + + constructor( + private _heroService: HeroService, + private _routeParams: RouteParams) { + } + + ngOnInit() { + let id = +this._routeParams.get('id'); + this._heroService.getHero(id) + .then(hero => this.hero = hero); + } + + goBack() { + window.history.back(); + } +} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.service.js b/Angular2-quickstart/app/hero.service.js index d989b78..1c8b36e 100644 --- a/Angular2-quickstart/app/hero.service.js +++ b/Angular2-quickstart/app/hero.service.js @@ -42,6 +42,10 @@ System.register(['angular2/core', './mock-heroes'], function(exports_1, context_ return HeroService; }()); exports_1("HeroService", HeroService); + getHero(id, number); + { + return Promise.resolve(mock_heroes_1.HEROES).then(function (heroes) { return heroes.filter(function (hero) { return hero.id === id; })[0]; }); + } } } }); diff --git a/Angular2-quickstart/app/hero.service.js.map b/Angular2-quickstart/app/hero.service.js.map index 09bb34d..faaf508 100644 --- a/Angular2-quickstart/app/hero.service.js.map +++ b/Angular2-quickstart/app/hero.service.js.map @@ -1 +1 @@ -{"version":3,"file":"hero.service.js","sourceRoot":"","sources":["hero.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAIA;gBAAA;gBAUA,CAAC;gBATC,+BAAS,GAAT;oBACE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC;gBACjC,CAAC;gBACD,kCAAkC;gBAClC,qCAAe,GAAf;oBACE,MAAM,CAAC,IAAI,OAAO,CAAS,UAAA,OAAO;wBAChC,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,CAAC,oBAAM,CAAC,EAAf,CAAe,EAAE,IAAI,CAAC;oBAArC,CAAqC,CAAC,YAAY;oBAAb,CAAC,YAAY;qBACnD,CAAC;gBACJ,CAAC;gBAVH;oBAAC,iBAAU,EAAE;;+BAAA;gBAWb,kBAAC;YAAD,CAAC,AAVD,IAUC;YAVD,qCAUC,CAAA"} \ No newline at end of file +{"version":3,"file":"hero.service.js","sourceRoot":"","sources":["hero.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAIA;gBAAA;gBAUA,CAAC;gBATC,+BAAS,GAAT;oBACE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC;gBACjC,CAAC;gBACD,kCAAkC;gBAClC,qCAAe,GAAf;oBACE,MAAM,CAAC,IAAI,OAAO,CAAS,UAAA,OAAO;wBAChC,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,CAAC,oBAAM,CAAC,EAAf,CAAe,EAAE,IAAI,CAAC;oBAArC,CAAqC,CAAC,YAAY;oBAAb,CAAC,YAAY;qBACnD,CAAC;gBACJ,CAAC;gBAVH;oBAAC,iBAAU,EAAE;;+BAAA;gBAWb,kBAAC;YAAD,CAAC,AAVD,IAUC;YAVD,qCAUC,CAAA;YAED,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;YAAC,CAAC;gBACnB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC,IAAI,CACjC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,EAAE,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC,CAAC,CAAC,EAAxC,CAAwC,CACnD,CAAC;YACJ,CAAC"} \ No newline at end of file diff --git a/Angular2-quickstart/app/hero.service.ts b/Angular2-quickstart/app/hero.service.ts index 8185262..c98b578 100644 --- a/Angular2-quickstart/app/hero.service.ts +++ b/Angular2-quickstart/app/hero.service.ts @@ -13,3 +13,10 @@ export class HeroService { ); } } + +getHero(id: number) { + return Promise.resolve(HEROES).then( + heroes => heroes.filter(hero => hero.id === id)[0] + ); +} + diff --git a/Angular2-quickstart/app/heroes.component.css b/Angular2-quickstart/app/heroes.component.css new file mode 100644 index 0000000..68a83e7 --- /dev/null +++ b/Angular2-quickstart/app/heroes.component.css @@ -0,0 +1,47 @@ +.selected { + background-color: #CFD8DC !important; + color: white; + } + .heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; + } + .heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; + } + .heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; + } + .heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; + } + .heroes .text { + position: relative; + top: -3px; + } + .heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; + } \ No newline at end of file diff --git a/Angular2-quickstart/app/heroes.component.html b/Angular2-quickstart/app/heroes.component.html new file mode 100644 index 0000000..f2462bf --- /dev/null +++ b/Angular2-quickstart/app/heroes.component.html @@ -0,0 +1,15 @@ +

{{title}}

+

My Heroes

+
    +
  • + {{hero.id}} {{hero.name}} +
  • +
+
+

+ {{selectedHero.name | uppercase}} is my hero +

+ +
\ No newline at end of file diff --git a/Angular2-quickstart/app/heroes.component.js b/Angular2-quickstart/app/heroes.component.js new file mode 100644 index 0000000..c08ee3e --- /dev/null +++ b/Angular2-quickstart/app/heroes.component.js @@ -0,0 +1,58 @@ +System.register(['angular2/core', './hero-detail.component', './hero.service'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1, hero_detail_component_1, hero_service_1; + var HeroesComponent; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }, + function (hero_detail_component_1_1) { + hero_detail_component_1 = hero_detail_component_1_1; + }, + function (hero_service_1_1) { + hero_service_1 = hero_service_1_1; + }], + execute: function() { + HeroesComponent = (function () { + function HeroesComponent(_router, _heroService) { + this._router = _router; + this._heroService = _heroService; + } + HeroesComponent.prototype.getHeroes = function () { + var _this = this; + this._heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes; }); + }; + HeroesComponent.prototype.ngOnInit = function () { + this.getHeroes(); + }; + HeroesComponent.prototype.onSelect = function (hero) { this.selectedHero = hero; }; + HeroesComponent.prototype.gotoDetail = function () { + this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + }; + HeroesComponent = __decorate([ + core_1.Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes.component.html', + styleUrls: ['app/heroes.component.css'], + directives: [hero_detail_component_1.HeroDetailComponent] + }), + __metadata('design:paramtypes', [Object, hero_service_1.HeroService]) + ], HeroesComponent); + return HeroesComponent; + }()); + exports_1("HeroesComponent", HeroesComponent); + } + } +}); +//# sourceMappingURL=heroes.component.js.map \ No newline at end of file diff --git a/Angular2-quickstart/app/heroes.component.js.map b/Angular2-quickstart/app/heroes.component.js.map new file mode 100644 index 0000000..e8dd3a0 --- /dev/null +++ b/Angular2-quickstart/app/heroes.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"heroes.component.js","sourceRoot":"","sources":["heroes.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAYA;gBAGE,yBACU,OAAe,EACf,YAAyB;oBADzB,YAAO,GAAP,OAAO,CAAQ;oBACf,iBAAY,GAAZ,YAAY,CAAa;gBAAI,CAAC;gBACxC,mCAAS,GAAT;oBAAA,iBAEC;oBADC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,EAApB,CAAoB,CAAC,CAAC;gBACrE,CAAC;gBACD,kCAAQ,GAAR;oBACE,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,CAAC;gBACD,kCAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;gBAClD,oCAAU,GAAV;oBACE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;gBACtE,CAAC;gBAtBH;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,WAAW;wBACrB,WAAW,EAAE,2BAA2B;wBACxC,SAAS,EAAG,CAAC,0BAA0B,CAAC;wBACxC,UAAU,EAAE,CAAC,2CAAmB,CAAC;qBAClC,CAAC;;mCAAA;gBAkBF,sBAAC;YAAD,CAAC,AAhBD,IAgBC;YAhBD,6CAgBC,CAAA"} \ No newline at end of file diff --git a/Angular2-quickstart/app/heroes.component.ts b/Angular2-quickstart/app/heroes.component.ts new file mode 100644 index 0000000..91ba25f --- /dev/null +++ b/Angular2-quickstart/app/heroes.component.ts @@ -0,0 +1,30 @@ +import {Component, OnInit} from 'angular2/core'; +import {Hero} from './hero'; +import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; +import {HeroDetailComponent} from './hero-detail.component'; +import {HeroService} from './hero.service'; +@Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes.component.html', + styleUrls: ['app/heroes.component.css'], + directives: [HeroDetailComponent] +}) + +export class HeroesComponent implements OnInit { + heroes: Hero[]; + selectedHero: Hero; + constructor( + private _router: Router, + private _heroService: HeroService) { } + getHeroes() { + this._heroService.getHeroes().then(heroes => this.heroes = heroes); + } + ngOnInit() { + this.getHeroes(); + } + onSelect(hero: Hero) { this.selectedHero = hero; } + gotoDetail() { + this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + } +} + diff --git a/Angular2-quickstart/index.html b/Angular2-quickstart/index.html index fdc480a..e45e242 100644 --- a/Angular2-quickstart/index.html +++ b/Angular2-quickstart/index.html @@ -1,5 +1,7 @@ + + Angular 2 QuickStart @@ -14,6 +16,8 @@ + +