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

79
Visualizações
Custom decorator and inheritance angular2

I've made custom property decorator:

export function Attr(label: MemberInfo) {

  return function (target: any, key: any) {

  if (!target.params) {
    target.params = [];
  }
  label.name = key;

  target.params.push(label);
};}

So now, I am able to wrte, something like that:

@Attr{...}
test:any;

And then, some info about member test is added to array params. The problem is that I have few levels of inheritance, and the target, passed to function decorator is always parent of particular class, i.e I would like to have such a structure:

classA -> ClassB
classA -> ClassC

ClassA is base class of classB and ClassC. ClassB and ClassC are inheriting array params from base class. Base classA adds some decorators, and that's what should be visible to both subclasses. The problem is that when I use decorator in ClassB an ClassC, everything is added to array params from base class.

As I understand inheritance, both classed have another "copy" of array params. What can I do to separate those two classes arrays, but still use core of params, declared in base class? Please help me :)

over 4 years ago · Santiago Trujillo
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