Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

77
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!