How to use a filter in javascript instead of the Html

I'm using angularJS and it's great. I can't find it in the Documentation - What is the equivalent in Javascript to this angular js expression:

<!-- html here -->
<body>
   <div>
...

{{ (myList| filter:mySearch).length }}
...

Thanks for the help

It's on Angular's filter documentation:

In HTML Template Binding

{{ filter_expression | filter:expression }}

In JavaScript

$filter('filter')(array, expression)

In your case, it would look something like $filter('filter')(myList, mySearch).

As an alternative syntax you can also inject a filter directly, without going through the $filter service. For example to inject filter filter to your controller you could write:

MyCtrl = function($scope, filterFilter) {

  $scope.filtered = filterFilter(myArray, expression);
}

A question very similar to How to use filter in controller in angularjs?

In your html

<input ng-model="search">
<div ng-repeat="thing in things | filter:searchResults"></div>

In your JS

$scope.$watch('search', function (newValue, oldValue) {
  var searchResults = filterFilter($scope.things, $scope.search);
});