Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

84
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda