0

I am currently working basic angular app and database using firebase. My Question is, How to filter the records in angular once loaded all the datas from firebase. I used to find many ways in Google. Finally, i got a solutions using OrderByPriority (Object to Array). Its working fine but the problem is, I got some error when i edited the existing records. I got this below error when i edit the records when i used the OrderByPriority.

**Error:** Firebase.set failed: First argument contains undefined

Code:

data-ng-repeat="(key,person) in contactList | orderByPriority | filter:searchCategory

My Apps Screen part - I have given left navigation part only,

Category
All        (5)
Family     (2)
Friends    (3)

My Questions are,

  1. How do i filter the data when i click the cateogry(Eg., All, Family, Friends etc.,) and display the records accordingly based on the selection?
  2. Also I need to count the records for 'All' Category.

I am waiting for your favorable reply. Thanks for advance.

1 Answer 1

1
  1. How do i filter the data when i click the cateogry(Eg., All, Family, Friends etc.,) and display the records accordingly based on the selection?

You will want your person records to have a category field. Then when a category is clicked, simply put it into $scope.searchCategory:

All ({{counts['all']}}) Family ({{counts['family']}})

  1. Also I need to count the records for 'All' Category.

Isn't this simply the total of the others?

Total: {{ counts['family'] + counts['friends'] }}

Or with a method in your controller:

$scope.totalCount = function() {
  var total = 0;
  angular.forEach(counts, function(x) { total += x; });
  return total;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.