23 lines
546 B
TypeScript
23 lines
546 B
TypeScript
import {Pipe, PipeTransform} from '@angular/core';
|
|
|
|
/**
|
|
* Filter Pipe to filter specific rank by level number in template
|
|
*
|
|
* @author: HardiReady
|
|
*/
|
|
|
|
@Pipe({name: 'rankfilter'})
|
|
export class FilterRankPipe implements PipeTransform {
|
|
|
|
transform(items: any[], filter: any): any {
|
|
// filter items array, items which match and return true will be kept, false will be filtered out
|
|
const res = items.filter(item => item.level === filter);
|
|
if (res.length === 0) {
|
|
return [{name: '-'}];
|
|
} else {
|
|
return res
|
|
}
|
|
}
|
|
|
|
}
|