C
C
cb77772020-08-28 10:19:23
JavaScript
cb7777, 2020-08-28 10:19:23

How to create one object from another with different names?

There is a field object

export interface Field {
  // Название
  name?:string;
  // Заголовок
  title?:string;
  // Номер по порядку
  position:number;
  // Ориентация
  orientation:Orientation;
  // Флаг, указывающий что по полю надо посчитать сумму итога
  totalSum:boolean;
}

how to convert it to an object of type columns for p-table type
, for example:
this.colsFields = [
{field: 'id', header: 'УИД поля'},
    ];

To take only title and name from the field object

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Kostenko, 2020-08-28
@ktim8168

Well, you need separate interfaces

interface BaseField {
  title?: string;
  name?: string;
}

interface Field extends BaseField {
  position: number;
  orientation: Orientation;
  totalSum: boolean;
}

interface ColField {
  field: BaseField;
  header: string;
  ...
}

this.colsFields: ColField[] = [
  ...
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question