angular-cn/tools
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
..
@angular/tsc-wrapped fix(tsc-wrapped): emit flat module format correctly on Windows (#15215) 2017-03-17 15:35:28 -05:00
build chore(build): remove unused build/util 2016-11-07 10:32:00 -08:00
cjs-jasmine refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
code.angularjs.org build(publish): remove unneeded add-license-to-rx (#12734) 2016-11-10 15:56:14 -08:00
gulp-tasks build: fix paths to typings files so tsickle resolves imports correctly 2017-03-16 17:34:29 -07:00
karma refactor: add license header to JS files & format files (#12081) 2016-10-04 20:39:20 -07:00
npm chore(npm): clean up clean-shrinkwrap script 2016-10-31 11:26:59 -07:00
public_api_guard feat(router): introduce `ParamMap` to access parameters 2017-03-20 09:19:32 -07:00
travis refactor: add license header to JS files & format files (#12081) 2016-10-04 20:39:20 -07:00
tree-shaking-test refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
tsc-watch refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
tslint fix: build and test fixes for TS 2.1 (#13294) 2017-02-08 11:32:40 -06:00
validate-commit-message fix: validation messages support animations scope 2017-02-10 19:05:00 -06:00
check-environment.js build: allow check-environment.js to be run directly 2017-03-05 08:41:26 -08:00
chromedriverpatch.js refactor: add license header to JS files & format files (#12081) 2016-10-04 20:39:20 -07:00
jsconfig.json chore(vscode): add jsconfig.json and remove .settings dir 2015-10-29 13:53:21 +00:00
tsconfig.json build(aio): move doc-gen stuff from angular.io (#14097) 2017-01-26 23:46:59 -08:00
types.d.ts fix(fakeAsync): have fakeAsync use Proxy zone. (#10797) 2016-08-19 12:10:53 -07:00
utils.inc feat(bundle): add script to push bundles to code.angularjs.org 2015-04-14 14:50:53 -07:00