i have a data in firebase like this:
firebase_data {
-JGc5X37NDuvmJylmx0s: Object {
name: 'John Doe',
age: 21
}
-JGnGJlTjyAxFT-Vn48Y: Object {
name: 'Jane Doe',
age: 22
}
}
in my controller:
$scope.firebase = $firebase(new Firebase("https://firebase_data.firebaseio.com"));
my view:
<input type="text" ng-model="search" />
<ul ng-repeat="(key, value) in firebase | filter:search">
<li><a href="{{ key }}">{{ value.name }}</a></li>
</ul>
the filter is not working. how can i make the filter work?
Use orderByPriority to convert your Firebase object to an array.
<input type="text" ng-model="search" />
<ul ng-repeat="(key, value) in firebase | orderByPriority | filter:search">
<li><a href="{{ key }}">{{ value.name }}</a></li>
</ul>
I think firebase returns as object and angular's filter will filter only arrays and does not filter object
You can create custom filter and filter. I have created example for that using firebase object
http://plnkr.co/edit/tiSsswXQWgAPPv6ozqOm?p=preview
Please let me know if anything
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With