angular.js - angularjs通过url怎么传递多个参数?

浏览:26日期:2023-02-06

问题描述

HTML:

<a ng-click='onGoDetail(y.id);'><img ng-src='https://www.6hehe.com/wenda/imgurl/1.jpg' /></a>

JS:

$scope.onGotDetail=function(pNo) { window.location.href='https://www.6hehe.com/wenda/detail.html?pNo='+pNo; };

url如 http://1.1.1.1/report.html?pNo=123 使用这样方法可以在跳转页面的同时传递一个url上面的pNo=123参数给目的页面,但是想一次传递多个参数呢?比如2个参数,一个id,一个key。那HTML页得怎么写?js页面又得怎么写?刚接触angularjs不久,请前辈指导指导。

问题解答

回答1:

介个。传多个参数的话就拼多个参数咯:

window.location.href='https://www.6hehe.com/wenda/detail.html?id='+id+'&key='+key;

当然既然你用了angular,就用angular的$location吧,

参见:$location

相关文章: