Last active
March 11, 2020 16:13
-
-
Save rakia/09ee9ff620246a7c0903893e7a117b09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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