Commit Graph

10 Commits

Author SHA1 Message Date
Igor Minar 091a504377 Revert "fix(router): change processing url tree children condition (#26243)" (#27516)
This reverts commit ccc77ca441.

Breaks Pantheon see cl/224256517.

PR Close #27516
2018-12-06 09:17:20 -08:00
miginmrs ccc77ca441 fix(router): change processing url tree children condition (#26243)
stop adding next path of pathless activated route to the url

PR Close #26224

PR Close #26243
2018-12-05 10:39:30 -08:00
Igor Minar b43f8bc7d3 feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)
PR Close #22573
2018-03-19 21:51:51 -07:00
Misko Hevery 3d50fd7cac build: add bazel test rules for remainder of packages (#21053)
PR Close #21053
2017-12-22 13:10:51 -08:00
Miško Hevery bc431888f3 fix(router): Update types for TypeScript nullability support
This reverts commit ea8ffc9841.
2017-04-18 12:07:33 -07:00
Tobias Bosch ea8ffc9841 Revert "fix(router): Update types for TypeScript nullability support"
This reverts commit 56c46d70f7.

Broke in G3.
2017-04-17 09:56:09 -07:00
Miško Hevery 56c46d70f7 fix(router): Update types for TypeScript nullability support 2017-04-14 14:31:17 -07:00
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
Victor Berchet 029d0f25e5 fix(router): fix query parameters with multiple values (#15129)
fixes #14796
2017-03-15 15:27:19 -07:00
Jason Aden 3e51a19983 refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00