angular-cn/modules
Victor Berchet a755b715ed feat(router): introduce `ParamMap` to access parameters
The Router use the type `Params` for all of:
- position parameters,
- matrix parameters,
- query parameters.

`Params` is defined as follow `type Params = {[key: string]: any}`

Because parameters can either have single or multiple values, the type should
actually be `type Params = {[key: string]: string | string[]}`.

The client code often assumes that parameters have single values, as in the
following exemple:

```
class MyComponent {
sessionId: Observable<string>;

constructor(private route: ActivatedRoute) {}

ngOnInit() {
    this.sessionId = this.route
      .queryParams
      .map(params => params['session_id'] || 'None');
}
}

```

The problem here is that `params['session_id']` could be `string` or `string[]`
but the error is not caught at build time because of the `any` type.

Fixing the type as describe above would break the build because `sessionId`
would becomes an `Observable<string | string[]>`.

However the client code knows if it expects a single or multiple values. By
using the new `ParamMap` interface the user code can decide when it needs a
single value (calling `ParamMap.get(): string`) or multiple values (calling
`ParamMap.getAll(): string[]`).

The above exemple should be rewritten as:

```
class MyComponent {
sessionId: Observable<string>;

constructor(private route: ActivatedRoute) {}

ngOnInit() {
    this.sessionId = this.route
      .queryParamMap
      .map(paramMap => paramMap.get('session_id') || 'None');
}
}

```

Added APIs:
- `interface ParamMap`,
- `ActivatedRoute.paramMap: ParamMap`,
- `ActivatedRoute.queryParamMap: ParamMap`,
- `ActivatedRouteSnapshot.paramMap: ParamMap`,
- `ActivatedRouteSnapshot.queryParamMap: ParamMap`,
- `UrlSegment.parameterMap: ParamMap`
2017-03-20 09:19:32 -07:00
..
angular1_router docs: branding fixes (#14132) 2017-01-27 15:03:11 -06:00
benchmarks refactor(core): view engine - change `BindingType` to `BindingFlags` (#15251) 2017-03-19 12:21:37 -05:00
benchmarks_external refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
e2e_util feat(core): add initial view engine (#14014) 2017-01-20 13:10:57 -08:00
payload_tests/hello_world/ts docs: branding fixes (#14132) 2017-01-27 15:03:11 -06:00
playground feat(router): introduce `ParamMap` to access parameters 2017-03-20 09:19:32 -07:00
rollup-test feat: update RxJS peer dependency to 5.0.0-rc.4 2016-11-29 16:27:33 -08:00
empty.ts refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
es6-subset.d.ts refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
system.d.ts refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
tsconfig.json refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
types.d.ts refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00