Filter Operator in Angular Observable

The Filter Operator in Angular filters the items emitted by the source Observable by using a condition (predicate). It emits only those values, which satisfies the condition and ignores the rest.

Filter in Angular

Filter is the simplest and most used RxJs Operator in Angular. The Filter Operator takes 2 arguments.


The first argument is the predicate function. This function is evaluated against each value of the source observable. Filter emits only those values which satisfies the the predicate. The predicate function takes 2 parameters. The first one is the value emitted by the source. The second argument is zero based index

The second argument thisArg is Optional. It determines the value of this in the predicate function

Filter Example

The following example filter function returns true only if the value is an even number.

Source Code

Filter Empty or undefined

Filter object or array

Source Code



Read More

1 thought on “Filter Operator in Angular Observable”

  1. fromArray is only available in rxjs version 6 I believe. Please verify you version of ‘rxjs’ in package.json if you have issues importing.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top