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

129
Vistas
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
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