Skip to content

Commit

Permalink
feat: parammap in ng4
Browse files Browse the repository at this point in the history
  • Loading branch information
cexbrayat committed Mar 22, 2017
1 parent 220e0bf commit 632337d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions _posts/2017-03-16-what-is-new-angular-4.md
Expand Up @@ -187,6 +187,25 @@ A new directive has been added to help you compare options from a select: `compa

# Router

## ParamMap

A new interface has been introduced to represent the parameters
of a URL: `ParamMap`.
Instead of using `params` or `queryParams`,
you should now use `paramMap` or `queryParamMap`,
because they offer the choice between `get()` to get a value,
or `getAll()` to get all values (as query parameters can have multiple values for example).

const id = this.route.snapshot.paramMap.get('ponyId');
this.ponyService.get(id).subscribe(pony => this.pony = pony);

or as an Observable:

this.route.paramMap
.map((params: ParamMap) => params.get('ponyId'))
.switchMap(id => this.ponyService.get(id))
.subscribe(pony => this.pony = pony);

## CanDeactivate

The `CanDeactivate` interface now has an extra (optional) parameter,
Expand Down

0 comments on commit 632337d

Please sign in to comment.