Created
March 29, 2020 23:04
-
-
Save guiseek/1613abe7f43f43f196ea302d486307f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Função | |
export const addColumn = <T = any>(prop: string) => { | |
const shift = prop.split('.').pop(); | |
return (payload: T): T => { | |
const column = prop.split('.') | |
.reduce((p, c) => payload[p][c]); | |
return ({ ...payload, [shift]: column }); | |
} | |
} | |
This file contains hidden or 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
<!-- Facilita o search usando DataSource filter --> | |
<ng-container matColumnDef="name"> | |
<mat-header-cell *matHeaderCellDef mat-sort-header>Nome</mat-header-cell> | |
<mat-cell *matCellDef="let row"> | |
<span class="text-truncate">{{ row.name }}</span> | |
</mat-cell> | |
</ng-container> |
This file contains hidden or 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
// Exemplo de uso | |
this.service | |
.findEvaluations() | |
.valueChanges() | |
.pipe( | |
takeUntil(this.destroy$), | |
map(d => d.map(addColumn('patient.name'))) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment