Bre*_*ett 3 angular2-routing angular
在Angular 2中,如何在URL中包含问号和等号?我尝试了以下两种方式:
在html中:
routerLink="./Example?tour=true"
Run Code Online (Sandbox Code Playgroud)
在TypeScript中:
this.router.navigate(['/Example?tour=true']);
Run Code Online (Sandbox Code Playgroud)
这两个例子都导致: /Example%3Ftour%3Dtrue
如何让我的URL工作并显示我想要的方式?
我相信这就是你要找的东西:添加queryParams对象.
this.router.navigate(['/Example'], {queryParams:{tour:true}});
Run Code Online (Sandbox Code Playgroud)
编辑:记录在这里:https://angular.io/docs/ts/latest/api/router/index/NavigationExtras-interface.html#!#queryParams-anchor
| 归档时间: |
|
| 查看次数: |
697 次 |
| 最近记录: |