chore(ts): updating to beta.16
This commit is contained in:
parent
3bc94147a7
commit
0a606a1b41
|
@ -3,9 +3,10 @@ import { bootstrap } from 'angular2/platform/browser';
|
|||
import { provide } from 'angular2/core';
|
||||
import { XHRBackend } from 'angular2/http';
|
||||
|
||||
import { ROUTER_PROVIDERS } from 'angular2/router';
|
||||
|
||||
import { LocationStrategy,
|
||||
HashLocationStrategy,
|
||||
ROUTER_PROVIDERS } from 'angular2/router';
|
||||
HashLocationStrategy } from 'angular2/platform/common';
|
||||
|
||||
import { HeroData } from './hero-data';
|
||||
import { InMemoryBackendService,
|
||||
|
|
|
@ -3,10 +3,12 @@ import {provide}
|
|||
from 'angular2/core';
|
||||
import {bootstrap}
|
||||
from 'angular2/platform/browser';
|
||||
import {
|
||||
} from 'angular2/router';
|
||||
import {
|
||||
LocationStrategy,
|
||||
HashLocationStrategy
|
||||
} from 'angular2/router';
|
||||
} from 'angular2/platform/common';
|
||||
// #enddocregion ng2import
|
||||
|
||||
// #docregion appimport
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
// #docplaster
|
||||
//#docregion
|
||||
import { Injector } from 'angular2/core';
|
||||
import { ReflectiveInjector } from 'angular2/core';
|
||||
|
||||
import {Car, Engine, Tires} from './car';
|
||||
import {Logger} from '../logger.service';
|
||||
|
||||
//#docregion injector
|
||||
export function useInjector() {
|
||||
var injector:Injector;
|
||||
var injector:ReflectiveInjector;
|
||||
|
||||
//#enddocregion injector
|
||||
/*
|
||||
//#docregion injector-no-new
|
||||
// Cannot 'new' an Injector like this!
|
||||
var injector = new Injector([Car, Engine, Tires, Logger]);
|
||||
// Cannot 'new' an ReflectiveInjector like this!
|
||||
var injector = new ReflectiveInjector([Car, Engine, Tires, Logger]);
|
||||
//#enddocregion injector-no-new
|
||||
*/
|
||||
|
||||
//#docregion injector
|
||||
//#docregion injector-create-and-call
|
||||
injector = Injector.resolveAndCreate([Car, Engine, Tires, Logger]);
|
||||
injector = ReflectiveInjector.resolveAndCreate([Car, Engine, Tires, Logger]);
|
||||
//#docregion injector-call
|
||||
var car = injector.get(Car);
|
||||
//#enddocregion injector-call
|
||||
|
|
|
@ -30,7 +30,7 @@ export class InjectorComponent {
|
|||
hero = this.heroService.getHeroes()[0];
|
||||
|
||||
get rodent() {
|
||||
let rous = this._injector.getOptional(ROUS);
|
||||
let rous = this._injector.get(ROUS, null);
|
||||
if (rous) {
|
||||
throw new Error('Aaaargh!')
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
<script src="https://code.angularjs.org/tools/system.js"></script>
|
||||
<script src="https://code.angularjs.org/tools/typescript.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2.dev.js"></script>
|
||||
|
||||
<!-- 2. Configure SystemJS -->
|
||||
<script>
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
<script src="https://code.angularjs.org/tools/system.js"></script>
|
||||
<script src="https://code.angularjs.org/tools/typescript.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2.dev.js"></script>
|
||||
|
||||
<!-- 2. Configure SystemJS -->
|
||||
<script>
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
<script src="https://code.angularjs.org/tools/system.js"></script>
|
||||
<script src="https://code.angularjs.org/tools/typescript.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2-polyfills.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/Rx.js"></script>
|
||||
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2.dev.js"></script>
|
||||
|
||||
<!-- 2. Configure SystemJS -->
|
||||
<script>
|
||||
|
|
|
@ -19,22 +19,21 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"angular2": "2.0.0-beta.15",
|
||||
"angular2": "2.0.0-beta.16",
|
||||
"systemjs": "0.19.26",
|
||||
"es6-shim": "^0.35.0",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"zone.js": "0.6.10",
|
||||
"zone.js": "^0.6.12",
|
||||
|
||||
"a2-in-memory-web-api": "^0.1.15",
|
||||
"a2-in-memory-web-api": "^0.1.16",
|
||||
"bootstrap": "^3.3.6"
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^2.0.0",
|
||||
"lite-server": "^2.2.0",
|
||||
"typescript": "^1.8.10",
|
||||
"typings":"^0.7.12",
|
||||
"typings": "^0.8.1",
|
||||
|
||||
"canonical-path": "0.0.2",
|
||||
"http-server": "^0.9.0",
|
||||
|
@ -44,8 +43,8 @@
|
|||
"karma-cli": "^0.1.2",
|
||||
"karma-htmlfile-reporter": "^0.2.2",
|
||||
"karma-jasmine": "^0.3.8",
|
||||
"protractor": "^3.2.2",
|
||||
"protractor": "^3.3.0",
|
||||
"rimraf": "^2.5.2"
|
||||
},
|
||||
"repository": { }
|
||||
"repository": {}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<a href="#flying-heroes-impure">Flying Heroes filter pipe (impure)</a><br>
|
||||
<a href="#hero-message">Async Hero Message and AsyncPipe</a><br>
|
||||
<a href="#hero-list">Hero List with caching FetchJsonPipe</a><br>
|
||||
<a href="#random-pipe">Random Pipe (pure pipe / impure function)</a><br>
|
||||
|
||||
|
||||
<hr>
|
||||
|
@ -81,8 +80,4 @@
|
|||
<a id="hero-list"></a>
|
||||
<hero-list></hero-list>
|
||||
|
||||
<hr>
|
||||
<a id="random-pipe"></a>
|
||||
<random-pipe></random-pipe>
|
||||
|
||||
<div style="margin-top:12em;"></div>
|
||||
|
|
|
@ -10,7 +10,6 @@ import {HeroBirthday2} from './hero-birthday2.component';
|
|||
import {HeroListComponent} from './hero-list.component';
|
||||
import {PowerBooster} from './power-booster.component';
|
||||
import {PowerBoostCalculator} from './power-boost-calculator.component';
|
||||
import {RandomPipeComponent} from './random-pipe.component';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
|
@ -21,8 +20,7 @@ import {RandomPipeComponent} from './random-pipe.component';
|
|||
HeroBirthday,
|
||||
HeroBirthday2,
|
||||
HeroListComponent,
|
||||
PowerBooster, PowerBoostCalculator,
|
||||
RandomPipeComponent
|
||||
PowerBooster, PowerBoostCalculator
|
||||
],
|
||||
providers:[HTTP_PROVIDERS]
|
||||
})
|
||||
|
|
|
@ -11,8 +11,8 @@ import {Pipe, PipeTransform} from 'angular2/core';
|
|||
*/
|
||||
@Pipe({name: 'exponentialStrength'})
|
||||
export class ExponentialStrengthPipe implements PipeTransform {
|
||||
transform(value:number, [exponent]) : number {
|
||||
var exp = parseFloat(exponent);
|
||||
transform(value: number, exponent: string): number {
|
||||
let exp = parseFloat(exponent);
|
||||
return Math.pow(value, isNaN(exp) ? 1 : exp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ export class FetchJsonPipe implements PipeTransform{
|
|||
|
||||
constructor(private _http: Http) { }
|
||||
|
||||
transform(url:string):any {
|
||||
transform(url: string): any {
|
||||
if (url !== this.prevUrl) {
|
||||
this.prevUrl = url;
|
||||
this.fetched = null;
|
||||
this._http.get(url)
|
||||
.map( result => result.json() )
|
||||
.subscribe( result => this.fetched = result )
|
||||
.subscribe( result => this.fetched = result );
|
||||
}
|
||||
|
||||
return this.fetched;
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
import {Component} from 'angular2/core';
|
||||
import {Pipe, PipeTransform} from 'angular2/core';
|
||||
|
||||
// #docregion pipe
|
||||
// Pure pipe
|
||||
@Pipe({ name: 'randomizer' })
|
||||
export class RandomizerPipe implements PipeTransform {
|
||||
// Impure function
|
||||
transform() { return Math.random() * 10 ;}
|
||||
}
|
||||
// #enddocregion pipe
|
||||
|
||||
@Component({
|
||||
selector: 'random-pipe',
|
||||
template: `
|
||||
<h2>Random Pipe (pure pipe/impure function)</h2>
|
||||
<input #box (input)="0">
|
||||
<p>Input value: {{box.value}}</p>
|
||||
<p>Random pipe output: {{box.value | randomizer}}</p>
|
||||
`,
|
||||
pipes: [RandomizerPipe]
|
||||
})
|
||||
export class RandomPipeComponent {
|
||||
}
|
|
@ -7,11 +7,11 @@
|
|||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"angular2": "2.0.0-beta.15",
|
||||
"angular2": "2.0.0-beta.16",
|
||||
"es6-shim": "^0.35.0",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"zone.js": "0.6.10"
|
||||
"zone.js": "0.6.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^2.0.0",
|
||||
|
|
|
@ -11,17 +11,17 @@
|
|||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"angular2": "2.0.0-beta.15",
|
||||
"angular2": "2.0.0-beta.16",
|
||||
"systemjs": "0.19.26",
|
||||
"es6-shim": "^0.35.0",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"zone.js": "0.6.10"
|
||||
"zone.js": "0.6.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^2.0.0",
|
||||
"lite-server": "^2.2.0",
|
||||
"typescript": "^1.8.10",
|
||||
"typings":"^0.7.12"
|
||||
"typings":"^0.8.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import {AppComponent} from './app.component';
|
|||
// Add these symbols to override the `LocationStrategy`
|
||||
import {provide} from 'angular2/core';
|
||||
import {LocationStrategy,
|
||||
HashLocationStrategy} from 'angular2/router';
|
||||
HashLocationStrategy} from 'angular2/platform/common';
|
||||
// #enddocregion
|
||||
/* Can't use AppComponent ... but display as if we can
|
||||
// #docregion
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export * from 'angular2/router';
|
||||
|
||||
import { Directive, DynamicComponentLoader, ElementRef,
|
||||
import { Directive, DynamicComponentLoader, ViewContainerRef,
|
||||
Injectable, Optional, Input } from 'angular2/core';
|
||||
|
||||
import { PromiseWrapper } from 'angular2/src/facade/promise';
|
||||
|
@ -52,11 +52,11 @@ export class MockRouterOutlet extends RouterOutlet {
|
|||
name: string = null;
|
||||
|
||||
constructor(
|
||||
_elementRef: ElementRef,
|
||||
_viewContainerRef: ViewContainerRef,
|
||||
@Optional() _loader: DynamicComponentLoader,
|
||||
_parentRouter: Router,
|
||||
nameAttr: string) {
|
||||
super(_elementRef, _loader, _parentRouter, nameAttr);
|
||||
super(_viewContainerRef, _loader, _parentRouter, nameAttr);
|
||||
if (nameAttr) {
|
||||
this.name = nameAttr;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"icon": "home",
|
||||
"title": "Angular Docs",
|
||||
"menuTitle": "Docs Home",
|
||||
"banner": "Welcome to <b>Angular in JavaScript</b>! The current Angular 2 release is <b>beta.15</b>. Please consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'> Change Log</a> about recent enhancements, fixes, and breaking changes."
|
||||
"banner": "Welcome to <b>Angular in JavaScript</b>! The current Angular 2 release is <b>beta.16</b>. Please consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'> Change Log</a> about recent enhancements, fixes, and breaking changes."
|
||||
},
|
||||
|
||||
"quickstart": {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"icon": "home",
|
||||
"title": "Angular Docs",
|
||||
"menuTitle": "Docs Home",
|
||||
"banner": "Welcome to <b>Angular in TypeScript</b>! The current Angular 2 release is <b>beta.15</b>. Please consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'> Change Log</a> about recent enhancements, fixes, and breaking changes."
|
||||
"banner": "Welcome to <b>Angular in TypeScript</b>! The current Angular 2 release is <b>beta.16</b>. Please consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'> Change Log</a> about recent enhancements, fixes, and breaking changes."
|
||||
},
|
||||
|
||||
"quickstart": {
|
||||
|
|
|
@ -871,7 +871,8 @@ p.
|
|||
They are retrieved by calling `injector.get`.
|
||||
|
||||
The `get` method throws an error if it can't resolve the requested service.
|
||||
We can call `getOptional` instead, which we do in one case
|
||||
We can call `get` with a second parameter (the value to return if the service is not found)
|
||||
instead, which we do in one case
|
||||
to retrieve a service (`ROUS`) that isn't registered with this or any ancestor injector.
|
||||
|
||||
.l-sub-section
|
||||
|
|
|
@ -386,33 +386,21 @@ figure.image-display
|
|||
|
||||
a(id="pure-pipe-pure-fn")
|
||||
:marked
|
||||
### Pure pipes vs. pure functions
|
||||
### Pure pipes and pure functions
|
||||
|
||||
When developers first hear of *pure pipes* many of them think these pipes must be *pure functions*.
|
||||
A pure pipe uses pure functions.
|
||||
|
||||
Pure functions process inputs and return values without detectable side-effects.
|
||||
Given the same input they should always return the same output.
|
||||
|
||||
Pure pipes _are_ typically implemented with pure function.
|
||||
The pipes we saw earlier in this chapter were implemented with pure functions.
|
||||
The built-in `DatePipe` is a pure pipe with a pure function implementation.
|
||||
So is our `ExponentialStrengthPipe`.
|
||||
So is our `FlyingHeroesPipe`.
|
||||
|
||||
But there is no necessary connection between a pure pipe and a pure function.
|
||||
A few steps back we reviewed the `FlyingHeroesImpurePipe` — *an impure pipe with a pure function*.
|
||||
|
||||
We can also write *a pure pipe with an impure function* such as the
|
||||
`RandomizerPipe` (also in the [live example](/resources/live-examples/pipes/ts/plnkr.html))
|
||||
that ignores its input value and outputs a random number. Clearly an impure function!
|
||||
Yet it's perfectly well behaved as a pure pipe.
|
||||
+makeExample('pipes/ts/app/random-pipe.component.ts', 'pipe','app/random-pipe.component.ts (pipe)')(format='.')
|
||||
:marked
|
||||
When the input changes, it outputs a new value albeit never the same value for the same input.
|
||||
|
||||
Remember *purity in a pipe has nothing to do with pure functions!*
|
||||
|
||||
*Pipe purity* is more about the purity of the input values than of the pipe itself.
|
||||
But a *pure pipe* must always be implemented with a *pure function*. Failure to heed this warning will bring about many a console errors regarding expressions that have changed after they were checked.
|
||||
|
||||
.l-main-section
|
||||
:marked
|
||||
|
@ -471,4 +459,3 @@ code-example(format="." language="html")
|
|||
|
||||
If these performance and minification considerations do not apply to you, you can always create your own such pipes
|
||||
(along the lines of the [FlyingHeroesPipe](#impure-flying-heroes)) or find them in the community.
|
||||
|
||||
|
|
|
@ -41,52 +41,52 @@ var _rxData = [
|
|||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/angular2.dev.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/angular2.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/angular2-all.umd.dev.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/angular2-all.umd.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/angular2-all.umd.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/angular2-all.umd.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/angular2-all.umd.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/angular2-all.umd.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/angular2-polyfills.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/angular2-polyfills.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/rxjs/bundles/Rx.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/Rx.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/Rx.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/rxjs/bundles/Rx.umd.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/Rx.umd.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/Rx.umd.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/router.dev.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/router.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/router.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/http.dev.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/http.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/http.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/bundles/testing.dev.js',
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.15/testing.dev.js'
|
||||
to: 'https://code.angularjs.org/2.0.0-beta.16/testing.dev.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
from: 'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
|
||||
to: 'https://npmcdn.com/angular2@2.0.0-beta.15/es6/dev/src/testing/shims_for_IE.js'
|
||||
to: 'https://npmcdn.com/angular2@2.0.0-beta.16/es6/dev/src/testing/shims_for_IE.js'
|
||||
},
|
||||
{
|
||||
pattern: 'script',
|
||||
|
|
Loading…
Reference in New Issue