我创建了一个示例plunker,将多个参数传递到下一页,但它不起作用。这是一个plunker演示,点击项目后危机中心路由不起作用。
http://plnkr.co/edit/ngNSsKBzAuhaP0EjKVJX?p=preview
$bcheck=trim(strip_tags($_POST['bcheck']));
$dizi = explode(',',$bcheck);
$where = '';
foreach ($dizi as $diziyaz){
$where .= " OR urunozellikler.id='$diziyaz'";
}
$where = substr($where, 3);
$filtrele=mysql_query("SELECT DISTINCT * FROM urunler
INNER JOIN urunozellikler ON urunler.id = urunozellikler.urunid
WHERE ($where) AND urunler.dil='tr'
AND urunler.onay='1'");
while($filtreleyaz=mysql_fetch_array($filtrele)){
echo $filtreleyaz["urunad"];
}
//下面是路线:
onSelect(crisis: Crisis) {
// Navigate with Absolute link
//this.router.navigate(['/crisis-center', 1]); //this is working.
this.router.navigate(['/crisis-center', { id: '1', id2:'2'}]); //this is not working
}
我有三层导航,它从危机中心转移到危机细节,然后从危机细节转移到> transactiondetail。因此,在我导航到危机细节之后,我想通过危机清单和危机清单来回溯到详细信息,然后是危机清单。
我试图传递多个参数,这里有人有这个问题吗?
另外,我想隐藏浏览器网址中的网址参数并显示别名,以前用作“关键字”的关键字现在无效。
任何帮助表示赞赏
答案 0 :(得分:6)
使用路由器组件(来自' @ angular / router' ,而不是来自' @ angular / router-deprecated' ),你传递多个参数如下:
this.router.navigate(['/crisis-center', 1, 2]);
你试图这样做:
this.router.navigate(['/crisis-center', { id: '1', id2:'2'}]); //this is not working
因为您已将对象作为第二个参数传递,所以您传递的是查询参数而不是路由器参数。因此,它的URL是:
localhost:3000/crisis-center;id=1&id2=2
您可以在此处详细了解:https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters
答案 1 :(得分:4)
crisis-center/:id /:id2