set in html
<a
[routerLink]="['/servers', 5, 'edit']"
[queryParams]="{allowEdit: '1'}"
fragment="loading"
href="#"
class="list-group-item"
*ngFor="let server of servers">
{{ server.name }}
</a>
set in ts code
this.router.navigate(
['/servers', id, 'edit'],
{queryParams: {allowEdit: '1'},
fragment:'loading'});
retrieve query params
console.log(this.route.snapshot.queryParams);
console.log(this.route.snapshot.fragment);
this.route.queryParams.subscribe(
(params:Params) => {
console.log(params['id']);
}
);
this.route.fragment.subscribe(
(frag:string) => {
console.log(frag);
}
);
'IT' 카테고리의 다른 글
[angular] router nested (0) | 2018.03.22 |
---|---|
[angular] retrieve the data as number (0) | 2018.03.21 |
[angular] route and parameter (0) | 2018.03.19 |
[angular] Router navigate relatively (0) | 2018.03.19 |
[angular] Router Navigation programmatically (0) | 2018.03.19 |