我有点击功能。在第一次点击功能中,我为这个
添加现有网址的键值对$scope.OnItemClick = function (bedroom) {
$location.path("/builders/"+r.id).search({bedrooms:bedroom});
}
所以在剩余的函数中。我想根据现有的url
添加额外的键值对$scope.range = function (range) {
$location.path("/builders/"+r.id).search({budget:range});
}
$scope.status = function (status) {
$location.path("/builders/"+r.id).search({status:status});
}
我试图添加键值对,但它像这样相互骑行。
1st click : ../#/builders/1?bedrooms=1
2nd click :../#/builders/1?budget:5(overriding)
3rd click :../#/builders/1?status:9(overriding)
所以我想根据点击功能这样做:
../#/builders/1?budget=5&bedrooms=1&status=9
../#/builders/1?bedrooms=1&status=9&budget=5
../#/builders/1?bedrooms=1&budget=5&status=9
答案 0 :(得分:1)
$ location返回当前网址的搜索部分。
您可以这样做:
$scope.range = function (range) {
var current = $location.search();
current.budget = range;
$location.search(current);
}