Wesley Coetzee
Wesley Coetzee

Reputation: 4838

Angular 2, Extending a class

I'm trying to extend a method from inside this Angular package.

import { Component, OnInit, Injectable  } from '@angular/core';
import { FILE_UPLOAD_DIRECTIVES, FileUploader } from 'ng2-file-upload';

@Injectable()
export class FileUploadComponent extends FileUploader {

  constructor(public _myService: MyService) {
    super(arguments);
   }

  onAfterAddingFile(file: any) {
    file.withCredentials = false;
  }
}

Inside of the FileUploader class, this is the item I'm wanting to extend:

export declare class FileUploader {
  ...
  onAfterAddingFile(fileItem: any): any;
}

I found this, but I can't seem to get it to work. I'm needing to extend that class so that when a file is added to the FileUploader, it sets withCredentials to false, as this flag should not be true for my current needs.

Upvotes: 0

Views: 9873

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202146

You can't extend a component since you won't inherit the metadata of the parent component class.

This article could help you to understand what is the problem:

Upvotes: 3

Related Questions