Javascript 如何在GET请求中使用URL参数?

Javascript 如何在GET请求中使用URL参数?,javascript,angularjs,Javascript,Angularjs,我有一个非常简单的应用程序,它有两个特性。第一,它列出了所有的键。第二,它应该显示一个特定的键(以及相关的值) 以下是列出关键点的第一部分: var app = angular.module('flipDaSwitch', ['ngRoute']); app.controller('ListKeys', function($scope, $http) { $scope.getKeys = function() { $http.get('/api/keys'). suc

我有一个非常简单的应用程序,它有两个特性。第一,它列出了所有的键。第二,它应该显示一个特定的键(以及相关的值)

以下是列出关键点的第一部分:

var app = angular.module('flipDaSwitch', ['ngRoute']);

app.controller('ListKeys', function($scope, $http) {

  $scope.getKeys = function() {
    $http.get('/api/keys').
      success(function (data) {
        $scope.buckets = data;
      }).
      error(function (data){
        $scope.buckets = {}
      });
  };

});
我想知道如何从API中获取特定密钥。当前HTML:

<div name="listkeys" class="container">
  <div class="starter-template">
    <div ng-bind-html="message"></div>
    <table class="table table-striped table-bordered table-condensed sortable" ng-init="getKeys()">
      <tr>
        <th>Bucket:</th>
      </tr>
      <tr ng-repeat="bucket in buckets">
        <td>
          <a ng-href="/show_key.html#/key/{{bucket}}">{{bucket}}</a>
        </td>
      </tr>
    </table>
  </div>
</div>

我不确定如何根据URL参数发出get请求。

在控制器中注入
$routeParams

app.controller('ListKeys', function($scope, $http, $routeParams) {
...

关于这一点也有很多问题。

可能是重复的
app.controller('ListKeys', function($scope, $http, $routeParams) {
...