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

126
Views
Adding properties to Fabric Object in Angular 10

When trying to extend the fabric Text object with additional parameters in Angular, I'm successful up to the part of serializing it (e.g. the new property 'fieldname' shows up in JSON). However the code fails when trying to read it back using this.canvas.loadFromJSON

ERROR TypeError: Cannot read properties of undefined (reading 'fromObject')

My code for the extended Object looks like this:

interface ITextFieldOptions extends fabric.TextOptions {
    fieldname?: string;
}

export interface TextField extends ITextFieldOptions { }

export class TextField extends fabric.Text implements ITextFieldOptions {

  public constructor(options: ITextFieldOptions) {
    options.type = 'textField';
    options.text = '{'+options.fieldname+'}';
    super('initialize', options);
  }

  toObject(propertiesToInclude?: string[]): any {
    propertiesToInclude = (propertiesToInclude || []).concat(
      ['fieldname']
    );
    return super.toObject(propertiesToInclude);
  }

}

What am I missing to read my extended object back to the canvas?

about 4 years ago · Juan Pablo Isaza
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!