如何获取和过滤URL参数

时间:2015-08-03 05:05:37

标签: jquery json angularjs filter

我想询问是否可以获取并在事件下放置名称,开始日期和结束日期的URL参数,并将其设置在过滤器上。假设这是名称的URL。 http://staging.api.sample.com/events.json?name=johndrake和开始日期相同,链接events.json / start_date_from = 2015-01-01。任何人都有建议吗?帮助我们。这是我的1周试用和错误

Code be like:

     <!DOCTYPE html>
<html ng-app="myTable">
<head>
    <title>project  43</title>

   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.0/angular.min.js"></script>

<script type="text/javascript">
    var myTable=angular.module('myTable',[]);

  myTable.controller('tableCtrl',function($scope,$http){

  $http.get("http://staging.sample.com/events.json", {headers: {Authorization:  'vuNYhXbpKfH7dxks'}})

    .success(function(response) {
      debugger

     $scope.members=response.events;
     $scope.totals = response.paging;

    });

    });
    </script>
    </head>
    <body ng-controller="tableCtrl">


    <table border="5">
   <tr>
    <th>Event</th>
     <th>Account Shop</th>
     <th>Place</th>
     <th>Activity</th>
   </tr>

    <tr ng-repeat="member in members">
    <td>

    {{member.Event.name}}<br>  <!--names-->
    {{member.Event.id}}<br>
    {{member.Event.date_start}}<br>   <!--start date-->
    {{member.Event.date_end}}<br>     <!--end date-->


    <td>
    {{member.AccountShop.id}}<br>
    {{member.AccountShop.name}}<br>
    {{member.AccountShop.short_code}}<br>
    </td>

    <td >
    <div ng-repeat="Place in member.Place">
    {{Place.id}}<br>
    {{Place.name}}<br>
    {{Place.lk_country_code}}<br>
    </div>
    </td>

    <td>
    <div ng-repeat="Activity in member.Activity">
    {{Activity.id}}<br>
    {{Activity.short_description}}
    </div>

    </td>
    </table>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

对于标题,您可以使用&#34; $ http.defaults.headers.common [&#39;授权&#39;] =&#39; vuNYhXbpKfH7dxks&#39; &#34;而不是每次都发送相同的标题 并且您可以将数据作为对象发送 {
  名:&#39; johndrake&#39 ;,
  start_date_from:&#39; 2015年1月1日&#39;
}
发布数据后,他们将成为&#34; ?name = johndrake&amp; start_date_from = 2015-01-01&#34;