Skip to content

Instantly share code, notes, and snippets.

@rakia
Last active March 11, 2020 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakia/09ee9ff620246a7c0903893e7a117b09 to your computer and use it in GitHub Desktop.
Save rakia/09ee9ff620246a7c0903893e7a117b09 to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
import { TODO } from './todo.model';
@Pipe({
name: 'filterPerType',
pure: true
})
export class FilterPerTypePipe implements PipeTransform {
transform(allTodos: TODO[], type: string): TODO[] {
return allTodos.filter(todo => {
if (type === 'Coding' || type === 'Reading') {
return todo.type !== 'Writing';
} else {
return true;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment