如何在搜索字段上设置和获取URL参数

时间:2015-08-03 11:20:56

标签: jquery json angularjs search filter

有人可以纠正我这些代码的工作原理吗?我知道这些不是一个有效的代码。我在如何传递URL参数名称和开始日期方面遇到了麻烦。我想创建一个搜索按钮,如果您键入名称“peter”,然后再单击它。它会显示所有名称“peter”,然后显示 URL 。与开始日期相同,例如您键入2015-01-01 url

请帮助我们。我对这些没有任何想法。下面的代码就像是。

<!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("", {headers: {Authorization: 'vuNYhXbpKfH7dxkL4h1o2etBJDEiVrRdsds'}})
                        .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> 
                <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)

我希望,这段代码对你有所帮助。

<!doctype html>
<html lang="en">
 <head>
 <meta charset="UTF-8">
<title></title>


<script  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body ng-app="">
<div ng-init="friends = [{name:'John', date:'03-AUG-2015'},
                     {name:'Mary', date:'01-AUG-2015'},
                     {name:'Mike', date:'25-JUL-2015'},
                     {name:'Adam', date:'03-AUG-2015'},
                     {name:'Julie', date:'07-JUN-2015'},
                     {name:'Juliette', date:'23-FEB-2015'}]"></div>

 <label>Search: <input ng-model="searchText"></label>
 <div id="searchTextResults">
 <div ng-repeat="friend in friends | filter:searchText">
  <a href="http://staging.api.sample.com/events.json?name={{friend.name}}&&date={{friend.date}}">
{{friend.name}} | {{friend.date}} </a>  
</div>
</div>
</body>
</html>