-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
i have a base generic component and i want to call derived method from base class that return data that belongs to derived class.
i cant define it static in abstract class!
so the problem is, when i create new instance of derived class with {} as TDomain inside base generic class, its empty and method return null ref error !
Base Entity is like this:
export abstract class BaseEntity
{
abstract getColumns():string[];
}
My Model is Like this:
export class Person extends BaseEntity
{
getColumns() { return ["Id", "Name"]; }
}
I have a generic base component:
@Component({
selector: 'base-component',
templateUrl: './base.component.html',
styleUrls: ['./base.component.css']
})
export class BaseComponent<TDomain extends BaseEntity,TService extends DataService >
implements OnInit {
data:any[];
constructor() {
}
ExportToExcel(): void {
//must create an instance of derived class
//then call getcolumns method of it
### let obj = {} as TDomain; // but its empty doesnt work
### ExcelService.export(obj.getcolumns(this.data));
}
}
and derived component:
@Component({
selector: 'Derived-Cmp',
templateUrl: './derived.component.html',
styleUrls: ['./derived.component.css']
})
export class DerivedComponent extends BaseCrudComponent<Person,PersonService>
implements OnInit {
//ExportToExcel Method called form html
}
How Should i call derived class method from base generic class?
(in BaseComponent i want to call getcolumns on TDomain )
chharvey
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code