Pure pipe and impure pipe with examples
In Angular, pipes are used to transform data in templates. There are two types of pipes in Angular: pure pipes and impure pipes . These pipes are used to modify or format data before it is displayed to the user, but they differ in how they behave when the input data changes. Pure Pipes A pure pipe is a pipe that only executes when the input to the pipe changes. Angular executes pure pipes only when the input data or parameters passed to the pipe change . Pure pipes are more efficient because they don't execute unnecessarily when data hasn't changed. Pure Pipe Characteristics : It runs only when the input data changes (i.e., when the reference of the input changes). It is more efficient because Angular checks it less often. By default, Angular pipes are pure unless explicitly marked as impure. Impure Pipes An impure pipe runs every time change detection is triggered, regardless of whether the input data changes or not. This means impure pipes are executed on every componen...