diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/main.ts b/public/docs/_examples/cb-dependency-injection/ts/app/main.ts index b1e35e2a67..4873400039 100644 --- a/public/docs/_examples/cb-dependency-injection/ts/app/main.ts +++ b/public/docs/_examples/cb-dependency-injection/ts/app/main.ts @@ -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, diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/main.ts b/public/docs/_examples/cb-ts-to-js/ts/app/main.ts index 02535f55f8..03e7d81a5a 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/main.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/main.ts @@ -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 diff --git a/public/docs/_examples/dependency-injection/ts/app/car/car-injector.ts b/public/docs/_examples/dependency-injection/ts/app/car/car-injector.ts index a94202585c..f980f2fd83 100644 --- a/public/docs/_examples/dependency-injection/ts/app/car/car-injector.ts +++ b/public/docs/_examples/dependency-injection/ts/app/car/car-injector.ts @@ -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 diff --git a/public/docs/_examples/dependency-injection/ts/app/injector.component.ts b/public/docs/_examples/dependency-injection/ts/app/injector.component.ts index 9914e7d029..7640969183 100644 --- a/public/docs/_examples/dependency-injection/ts/app/injector.component.ts +++ b/public/docs/_examples/dependency-injection/ts/app/injector.component.ts @@ -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!') } diff --git a/public/docs/_examples/package.json b/public/docs/_examples/package.json index 4a8db4dcb8..19e66a662e 100644 --- a/public/docs/_examples/package.json +++ b/public/docs/_examples/package.json @@ -20,23 +20,21 @@ "author": "", "license": "ISC", "dependencies": { - "angular2": "2.0.0-beta.15", + "angular2": "angular/angular#2.0.0-build.cc86fee.js", "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.11", "a2-in-memory-web-api": "^0.1.15", "bootstrap": "^3.3.6" - }, "devDependencies": { "concurrently": "^2.0.0", "lite-server": "^2.2.0", - "typescript": "^1.8.10", - "typings":"^0.7.12", - + "typescript": "^1.9.0-dev.20160409", + "typings": "^0.7.12", "http-server": "^0.9.0", "jasmine-core": "~2.4.1", "karma": "^0.13.22", @@ -48,5 +46,5 @@ "protractor": "^3.2.2", "rimraf": "^2.5.2" }, - "repository": { } + "repository": {} } diff --git a/public/docs/_examples/pipes/ts/app/app.component.html b/public/docs/_examples/pipes/ts/app/app.component.html index f86ef24338..83856e4e91 100644 --- a/public/docs/_examples/pipes/ts/app/app.component.html +++ b/public/docs/_examples/pipes/ts/app/app.component.html @@ -10,7 +10,6 @@

Pipes

Flying Heroes filter pipe (impure)
Async Hero Message and AsyncPipe
Hero List with caching FetchJsonPipe
-Random Pipe (pure pipe / impure function)

@@ -81,8 +80,4 @@

Birthday Pipe Chaining

-
- - -
diff --git a/public/docs/_examples/pipes/ts/app/app.component.ts b/public/docs/_examples/pipes/ts/app/app.component.ts index 015715cc7e..e340783ab4 100644 --- a/public/docs/_examples/pipes/ts/app/app.component.ts +++ b/public/docs/_examples/pipes/ts/app/app.component.ts @@ -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] }) diff --git a/public/docs/_examples/pipes/ts/app/exponential-strength.pipe.ts b/public/docs/_examples/pipes/ts/app/exponential-strength.pipe.ts index 7164086f21..5db34b3107 100644 --- a/public/docs/_examples/pipes/ts/app/exponential-strength.pipe.ts +++ b/public/docs/_examples/pipes/ts/app/exponential-strength.pipe.ts @@ -11,7 +11,7 @@ import {Pipe, PipeTransform} from 'angular2/core'; */ @Pipe({name: 'exponentialStrength'}) export class ExponentialStrengthPipe implements PipeTransform { - transform(value:number, [exponent]) : number { + transform(value:number, [exponent]:string[]) : number { var exp = parseFloat(exponent); return Math.pow(value, isNaN(exp) ? 1 : exp); } diff --git a/public/docs/_examples/pipes/ts/app/random-pipe.component.ts b/public/docs/_examples/pipes/ts/app/random-pipe.component.ts deleted file mode 100644 index fe86108432..0000000000 --- a/public/docs/_examples/pipes/ts/app/random-pipe.component.ts +++ /dev/null @@ -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: ` -

Random Pipe (pure pipe/impure function)

- -

Input value: {{box.value}}

-

Random pipe output: {{box.value | randomizer}}

- `, - pipes: [RandomizerPipe] -}) -export class RandomPipeComponent { -} diff --git a/public/docs/_examples/router/ts/app/main.2.ts b/public/docs/_examples/router/ts/app/main.2.ts index 244050a36a..d96ba9c00e 100644 --- a/public/docs/_examples/router/ts/app/main.2.ts +++ b/public/docs/_examples/router/ts/app/main.2.ts @@ -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 diff --git a/public/docs/ts/latest/guide/dependency-injection.jade b/public/docs/ts/latest/guide/dependency-injection.jade index c2cfd5861e..96f003456a 100644 --- a/public/docs/ts/latest/guide/dependency-injection.jade +++ b/public/docs/ts/latest/guide/dependency-injection.jade @@ -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 diff --git a/public/docs/ts/latest/guide/pipes.jade b/public/docs/ts/latest/guide/pipes.jade index 4853df78d4..98b23f157d 100644 --- a/public/docs/ts/latest/guide/pipes.jade +++ b/public/docs/ts/latest/guide/pipes.jade @@ -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. -