我正在尝试使用angular-cli来获得AOT编译设置。我有一个从抽象类继承的指令,并且在编译期间出现错误,无法确定抽象类属于哪个模块。我不能将它添加到NgModule的声明数组中,那么有什么正确的方法可以解决这个问题呢?我的代码结构看起来像这样,Angular 2 angular-cli AOT在模块中声明抽象类?
//...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 in Cannot determine the module for class TutorialDirective in /test-app/src/app/tutorial/directive/tutorial.directive.ts!
我的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 { }
好一些调试后,如果我做它不是抽象的,它添加到声明它的作品。这是否意味着我不能将课程标记为抽象?这似乎不正确的...
为您的模块添加代码app.module.ts – Aravind
@Aravind ok。我无法将TutorialDirective添加到声明数组中。只是让你知道。 – Steveadoo
好吧,如果我不把它抽象并将它添加到声明它的工作。这是否意味着我不能将课程标记为抽象?这似乎不正确... – Steveadoo