angular-cn/packages
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
..
animations test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
benchpress refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
common test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
compiler test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
compiler-cli fix(platform-server): setup NoopAnimationsModule in ServerModule by default (#15131) 2017-03-17 16:21:51 -05:00
core test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
docs refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
examples feat(upgrade): use `ComponentFactory.inputs/outputs/ngContentSelectors` (#15214) 2017-03-17 13:52:50 -05:00
forms test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
http test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
language-service build: fix paths to typings files so tsickle resolves imports correctly 2017-03-16 17:34:29 -07:00
platform-browser test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
platform-browser-dynamic test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
platform-server test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
platform-webworker test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
platform-webworker-dynamic test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
router feat(router): introduce `ParamMap` to access parameters 2017-03-20 09:19:32 -07:00
upgrade test: add systemjs+umd integration test (#14196) 2017-03-19 12:23:07 -05:00
README.md refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
empty.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
es6-subset.d.ts refactor: update paths from modules/@angular to packages 2017-03-08 16:29:28 -08:00
license-banner.txt refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
router-license-banner.txt refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
system.d.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
tsconfig.json test(platform-server): add initial e2e tests for platform-server (#15061) 2017-03-14 17:11:39 -07:00
types.d.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

License: MIT