Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export abstract class using Angular 2 RC6 and NgModule

Tags:

angular

Angular 2 RC6 problem !!!

So imagine the situation where we have a standard class such as...

export abstract class FooBase {}

and then we want to export this class to be used by other modules within an Angular 2 RC6 web app, the NgModule code may look like this...

@NgModule({
    declarations: [FooBase],
    exports: [FooBase],
    imports: [CommonModule],
})
export class OurModule {}

Unfortunately when running this inside chrome it returns with...

Unexpected value 'FooBase' exported from module 'OurModule'

This base class is used to extend an existing class inside another module, simple stuff really, what am I doing wrong here !!!

like image 796
HeavenlyHost Avatar asked Sep 14 '16 07:09

HeavenlyHost


1 Answers

Don't use NgModule imports, exports, declarations for imports and exports of class declarations. @NgModule is only for components, directives, pipes and services.

Just use normal TypeScript imports and exports.

like image 195
Günter Zöchbauer Avatar answered Sep 25 '22 13:09

Günter Zöchbauer