Ste*_*doo 18 angular-cli angular
我正在尝试使用angular-cli进行AOT编译设置.我有一个从抽象类继承的指令,我在编译期间遇到一个错误,即angular无法确定抽象类属于哪个模块.我无法将它添加到NgModule的声明数组中,那么正确的方法是什么呢?我的代码结构如下所示,
//...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.
}
Run Code Online (Sandbox Code Playgroud)
错误看起来像这样
ERROR in Cannot determine the module for class TutorialDirective in /test-app/src/app/tutorial/directive/tutorial.directive.ts!
Run Code Online (Sandbox Code Playgroud)
我的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 { }
Run Code Online (Sandbox Code Playgroud)
好的经过一些调试,如果我把它变成抽象并将其添加到声明中就可以了.这是否意味着我不能将一个类标记为抽象?这似乎不对......
| 归档时间: |
|
| 查看次数: |
4608 次 |
| 最近记录: |