Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="table table-striped table-header-rotated" *ngIf="product.vin == old_VIN">
- <!-- Что-то такое? -->
- <thead>
- <tr>
- <!-- First column header is not rotated -->
- <th></th>
- <!-- Following headers are rotated -->
- <th class="rotate-45" *ngFor="let product of filter_product; let i=index;"><div><span>Договор {{i+1}}</span></div></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="row-header">Договор №</td>
- <td *ngFor="let product of filter_product;">{{product.treaty_number}</td>
- </tr>
- <tr>
- <td class="row-header">Улучшение условий</td>
- <td *ngFor="let product of filter_product;">{{product.improving_conditions}</td>
- </tr>
- <tr>
- <td class="row-header">VIN</td>
- <td *ngFor="let product of filter_product;">{{product.vin}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-striped table-header-rotated">
- <!-- Что-то такое? -->
- <thead>
- <tr>
- <!-- First column header is not rotated -->
- <th></th>
- <!-- Following headers are rotated -->
- <th><div><span>Договор 1</span></div></th>
- <th><div><span>Договор 2</span></div></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="row-header">Договор №</td>
- <td>2310-22</td>
- <td>1314-82</td>
- </tr>
- <tr>
- <td class="row-header">Улучшение условий</td>
- <td>Нет</td>
- <td>Нет</td>
- </tr>
- <tr>
- <td class="row-header">VIN</td>
- <td>X23254FSFS43</td>
- <td>X23254FSFS43</td>
- </tr>
- </tbody>
- </table>
- @Pipe({name: 'groupBy'})
- export class GroupByPipe implements PipeTransform {
- transform(value: Array<any>, field: string): Array<any> {
- const groupedObj = value.reduce((prev, cur)=> {
- if(!prev[cur[field]]) {
- prev[cur[field]] = [cur];
- } else {
- prev[cur[field]].push(cur);
- }
- return prev;
- }, {});
- return Object.keys(groupedObj).map(key => ({ key, value: groupedObj[key] }));
- }
- }
- table.table.table-striped.table-header-rotated(*ngFor="let products of filter_product | groupBy:'vin'")
- thead
- tr
- th
- th(*ngFor="let product of products.value; let i=index;") Договор {{ i + 1}}
- tbody
- tr
- td.row-header Договор №
- td(*ngFor="let product of products.value") {{ product.treaty_number }}
- tr
- td.row-header Улучшение условий
- td(*ngFor="let product of products.value") {{ product.improving_conditions }}
- tr
- td.row-header VIN
- td(*ngFor="let product of products.value") {{ product.vin }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement