Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
Typescript interface - add new value dynamically or create the interface dynamically

I have an Angular Material Table. Obviously, I have an interface from which is created the dataSource for the table. Is there any possibility to add a new value dynamically in the interface Or at least to create the interface dynamycally? Because the data which is coming from the backend it's unknown. Example: from this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
}

to this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  index: number;
}

or from this:

export interface PeriodicElement {}

to this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  index: number;
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

  1. It will be better to use it like,
export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  [key: string]: string | number;
}

or just

export interface PeriodicElement {
  [key: string]: string | number;
}
  1. Otherwise you can create separate models and use union(|) operator.

  2. Also you can use Partials to achieve this.

  3. For creating dynamically Refer here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda