HeavenlyHost
HeavenlyHost

Reputation: 95

How to export abstract class using Angular 2 RC6 and NgModule

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 !!!

Upvotes: 6

Views: 4766

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657937

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.

Upvotes: 12

Related Questions