我希望将搜索查询附加到JSON http.get请求,然后在收到数据时显示以下订单(之前我已访问过所有订单)
我正在使用并假设ng-model是这里的解决方案,但我努力用我当前的代码获得成功的JSON调用。
搜索页面(列表)
<ion-header-bar class="bar-dark">
<h2 class="title">Order List</h1>
</ion-header-bar>
<div class="bar bar-subheader item-input-inset bar-light">
<label class="item-input-wrapper">
<i class="icon ion-search placeholder-icon"></i>
<input type="search" ng-model="query" placeholder="Search">
</label>
</div>
<ion-content class="has-subheader">
<ion-list>
<ion-item ng-show="query" ng-repeat="order in orders | filter:query" class="item-thumbnail-left item-text-wrap"
href="#/tab/list/{{order.bkor_user}}">
<h2>Production Name: {{order.bkev_name}}</h2>
<h3>Seatcount: {{order.bkor_seatcount}}</h3>
<h2>Order Subtotal: £{{order.bkor_subtotal}}</h2>
</ion-item>
</ion-list>
</ion-content>
控制器
.controller('ListController', ['$scope', '$http', '$state','$cordovaBluetoothSerial', '$window', '$location', function($scope, $http, $state, $cordovaBluetoothSerial, $window, $location) {
$http.get('http://example.co.uk/bookingref/get/host/{{ query }}').success(function(data) {
$scope.orders = data;
$scope.query = query;
//console.log($scope.orders);
//console.log(JSON.stringify(config));
$scope.whichorder = $state.params.aId;
//console.log($scope.whichorder);
})
我想我现在也必须编辑我的ng-repeat,因为它是一个单一订单而不是一个订单数组
答案 0 :(得分:0)
您应该通过将参数连接到URL字符串将参数附加到字符串。
$http.get('http://example.co.uk/bookingref/get/host/'+ $scope.query)