March 2017
Intermediate to advanced
118 pages
2h 1m
English
Sometimes, however, you want to share some parameters across many activated routes, and that's what query params are for. For instance, given this URL /inbox/33?token=23756, we can access token in any component:
class ConversationCmp {
constructor(r: ActivateRoute) {
r.queryParams.forEach((p) => {
const token = p['token']
});
}
}
Since query parameters are not scoped, they should not be used to store route-specific information.
The fragment (for example, /inbox/33#fragment) is similar to query params:
class ConversationCmp {
constructor(r: ActivatedRoute) {
r.fragment.forEach((f:string) => {
});
}
}
Read now
Unlock full access