Skip to content
Middle4 views

How do pure and impure pipes detect updates to input data?

Practice

AI answer

In Angular, a pure pipe (the default) is recalculated when a primitive input changes, when the reference to an object/array passed to the pipe changes, or when its arguments change. Changes made to an object “in place” are usually not detected: you need to create a new reference. An impure pipe is checked during every change detection cycle, so it can noticeably affect performance; use it only when necessary.

items = [...items, newItem]; // new reference — the pure pipe will detect the change