如何在 angularjs 中传递查询字符串

How to pass query string in angularjs

我在完成列表的地方制作表格,并放置一些过滤器,如价格、型号。数据来自 json 我正在使用 like

$scope.getCarResource = $resource(urls, {}, {
      query: {method:'GET',headers: { 'Content-type': 'application/json'},cache:true,maxAge:3500000,params:{keyword:'@keyword',make:'@make',nit:'@nit'}}
    })`

现在我想像这样传递 url www.example.com?keyword=abc&make=233&nit=3 那么如何在 url 中传递 3 个或更多参数,以便它可以从 example.com 中获取数据 我也在使用 $routeParms,每当我说 $routeParams.keyword 时,它都会给出 undefined.

查询参数将在 $resource 方法的第二个参数中传递。这会将三个查询字符串参数附加到您的 urls 变量。

  $scope.getCarResource = $resource(urls, {keyword: 'abc', make: 233, nit: 3}, {
          query: {method:'GET',headers: { 'Content-type': 'application/json'},cache:true,maxAge:3500000,params:{keyword:'@keyword',make:'@make',nit:'@nit'}}
        })