过滤器功能在使用 Angular.js.and PHP 时无法按预期工作
Filter functionalty is not working as per expected using Angular.js.and PHP
我有一个问题。我需要使用 restaurant name
使用 Angular.js 从表中过滤数据。我有一个搜索框。如果用户键入名称的第一个字母,则应筛选与该字母相关的所有名称。它不是那样发生的。我在下面解释我的代码。
<div class="input-group" style="margin-bottom:10px; width:300px;">
<input class="form-control" placeholder="Type Restaurant Name" name="q" type="text" ng-model="searchProduct.rest_name">
</div>
<table class="table table-bordered table-striped table-hover" id="dataTable" >
<thead>
<tr>
<th>Sl. No</th>
<th>Restaurant Name</th>
</tr>
</thead>
<tbody id="detailsstockid">
<tr dir-paginate="cus in ($parent.labelResults=(listOfCustomerData | filter:searchProduct.rest_name:startsWith | orderBy:'rest_name')) | itemsPerPage:5 track by $index" current-page="currentPage">
<td>{{itemsPerPage *(currentPage-1)+$index+1}}</td>
<td>{{cus.rest_name}}</td>
</tr>
</tbody>
</table>
我的控制器端代码如下。
$http({
method:'GET',
url:"php/customerInfo.php?action=disp",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
console.log('res',response.data);
$scope.listOfCustomerData=response.data;
},function errorCallback(response) {
})
$scope.startsWith = function (actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}
在这里假设我有很多餐厅名称,如Anjum,A&P Chinese Food Express,Bookers BBQ & Crab Shack,Butcher And The Baker,Cactus Club Stephen Avenue,Cactus Club - Macleod Trail。在这里,当用户仅在搜索框中键入名称时,名称以应该过滤器开头,但不会那样发生。如果我将静态值分配给对象$scope.listOfCustomerData
则此功能按预期工作,但我使用 PHP 动态获取数据,但就我而言,它不会那样发生。请帮助我。
尝试使用这个 -
<input class="form-control" placeholder="Type Restaurant Name" name="q" type="text" ng-model="searchProduct">
</div>
<tr dir-paginate="cus in listOfCustomerData | filter:searchProduct | orderBy:'rest_name' | itemsPerPage:5 track by $index" current-page="currentPage">
在控制器中定义 - $scope.searchProduct = '';
- PHP Javascript显示/隐藏按钮不工作
- 如何使MailHandler.php在Wordpress中工作
- 如何检查这个代码点火器php函数是否工作,该函数是否在ajax url中使用
- 如何在php中创建一个函数,该函数与文本区域一起工作,通过输入类似[color:red]的内容来打印具有等效颜色的文本
- 如何使Jquery编码的动态下拉菜单与PHP GET变量协调工作
- Foreach无法在php和Jquery中工作
- document.title函数可以't设置它与php一起工作
- 递增 PHP 变量在 JSCRIPT 文档工作方面
- 类似按钮增量计数器不工作.PHP,AJAX,MySQL,javascript
- PHP:运行后变量不工作“;如果“;命令
- 为什么带有php-var的javascript代码不是't工作
- 无法使autocompletion与bootstrap和php代码点火器一起工作
- onClick按钮不工作javascript/php/jquery mobile
- Ajax调用PHP失败,ASP正常工作.NET
- JavaScript函数在php回显中工作吗?
- 使用HTML和任何服务器端语言(PHP,.net,ruby)制作的网站是否可以在每个具有浏览器的设备上工作
- 跨域AJAX不工作PHP
- .单击不工作(PHP)
- Ajax请求不工作php
- Jquery -确认对话框-工作php代码