add trackBy function
This commit is contained in:
parent
defdc2af4e
commit
488d3d5c2c
@ -1,5 +1,6 @@
|
||||
export interface IListable {
|
||||
readonly id: string;
|
||||
import { ITrackable } from './trackable';
|
||||
|
||||
export interface IListable extends ITrackable {
|
||||
readonly searchKey: string;
|
||||
readonly routerLink?: string;
|
||||
}
|
||||
|
||||
3
src/lib/listing/models/trackable.ts
Normal file
3
src/lib/listing/models/trackable.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface ITrackable {
|
||||
readonly id: string;
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { ITrackable } from '../listing/models/trackable';
|
||||
|
||||
export function capitalize(value: string): string {
|
||||
if (!value) {
|
||||
@ -25,3 +26,7 @@ export function toNumber(str: string): number {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function trackBy() {
|
||||
return <T extends ITrackable>(index: number, item: T): string => item.id;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user