I'm trying to get AOT compilation setup with angular-cli. I've got a directive that inherits from an abstract class, and I'm getting an error during compilation that angular can't determine what module the abstract class belongs to. I can't add it to the declarations array of the NgModule, so what's the right way to go about this? My code structure looks like this,
//...imports
export abstract class TutorialDirective {
//...base class logic
}
@Directive({
selector: '[tut]',
exportAs: 'tut'
})
export class DefaultTutorialDirective extends TutorialDirective {
//...calls into the base class for some shared stuff.
}
Error looks like this
ERROR in Cannot determine the module for class TutorialDirective in /test-app/src/app/tutorial/directive/tutorial.directive.ts!
My AppModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { TutorialService } from './tutorial/tutorial.service';
import { TutorialDirective, DefaultTutorialDirective } from './tutorial/directive/tutorial.directive';
@NgModule({
declarations: [
AppComponent,
DefaultTutorialDirective
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [TutorialService],
bootstrap: [AppComponent]
})
export class AppModule { }
Ok after some debugging, if I make it not abstract and add it to declarations it works. Does this mean I can't mark a class as abstract? That doesn't seem right...
Remove the @Component decorator from the abstract class, replacing it with an @Injectable() decorator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With