Angular JS 搜索过滤器不会使用 Firebase 过滤数据
Angular JS search filter is not filtering the data by using Firebase
我遇到的问题是搜索过滤器不过滤表。对问题可能是什么有什么建议或帮助吗?我正在制作的应用程序很简单,用户应输入两个文本字符串并将其保存,以便数据存储在Firebase数据库中。然后通过搜索过滤能力。但是,搜索不起作用。
单击此处访问 plunker
索引.html
<table class="table table-bordered">
<thead>
<th>Plate Number</th>
<th>Car Brand</th>
</thead>
<tbody>
<tr ng-repeat="customer in customers | filter:search">
<td>{{customer.CustomerPlateNumber}}</td>
<td>{{customer.CustomerCarBrand}}</td>
</tr>
</tbody>
</table>
脚本.js(使用 Firebase)
angular.module('myApp', []);
angular.module('myApp').controller('customerCtrl', function($scope) {
$scope.CustomerPlateNumber = "";
$scope.CustomerCarBrand = "";
$scope.customers = {};
$scope.myData = new Firebase("https://sizzling-torch-2102.firebaseio.com/CustomerInformation");
// PS, husk at CustomerPlatenumber: må være lik navnet på ng-model.
$scope.saveCustomerData = function() {
$scope.myData.push({CustomerPlateNumber: $scope.CustomerPlateNumber, CustomerCarBrand: $scope.CustomerCarBrand});
// Empty input after storing data
$scope.CustomerPlateNumber = "";
$scope.CustomerCarBrand = "";
};
// Two parameters, needs to know what its going to be fired upon, and a function that tells what to do when it is fired.
$scope.myData.on('value', function(snapshot) {
$scope.customers = snapshot.val();
//not recommended, look at "refresh bindings angular"
$scope.$apply();
});
});
问题是 $scope.customers 不是一个数组 [],而是一个复杂的 JavaScript 对象 {}。
如果将其更改为:
$scope.customers=[];
并将Firebase返回的复杂哈希表转换为数组,它可以工作(为了解释,我首先检查Firebase是否有返回数组的方法,而不是使用此特定的解释性代码):
$scope.myData.on('value', function(snapshot) {
var values = snapshot.val();
for(var myVal in values)
{
var item = values[myVal];
$scope.customers.push(item);
}
});
相关文章:
- 有可能过滤来自嵌入式YouTube的声音吗
- 将Firebase与Electron结合使用
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 无法将数据从firebase获取到我的html页面
- 如何将firebase数据传递到函数中
- Firebase2(Firebase.google.com)推送通知-从外部管理
- 为什么我的d3.jsselectAll+过滤器没有过滤
- 如何在iOS应用程序中从Firebase中删除超过6小时的数据
- 没有在Angular应用程序中定义firebase(在firebase迁移之后)
- Firebase-登录时获取url
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- Angular:使用选择列表选择过滤代码中的对象
- 在单击时过滤 JSON
- 如何在BookshelfJS中通过加入来过滤结果
- 如何在firebase中通过内部属性进行过滤
- 使用 Firebase 数据过滤 ng 重复
- Angular JS 搜索过滤器不会使用 Firebase 过滤数据
- Firebase排序和过滤
- Firebase实时数据库如何根据web应用程序的可用性过滤数据
- 如何使用 Firebase 按元素的子值过滤元素