将数组传递给 angularJs 中的 $location.search

pass array to $location.search in angularJs

我有一组用户 ID。我想将用户 ID 传递给 $location.search

$scope.userIds = [1, 2];
$location.search({'userId[]' : $scope.userIds}).path('/search');

它给出了 URL

/search?userId%5B%5D=1&userId%5B%5D=2

如果我删除 %5B%5D 不需要的字符,它就可以工作

如何删除它们?

删除不需要的字符尝试像这样删除“[]”:

$location.search({'userId': $scope.userIds}).path('/search')  

希望对您有所帮助