Tôi đang cố gắng thiết lập biên dịch AOT bằng angular-cli. Tôi đã có một chỉ thị kế thừa từ một lớp trừu tượng, và tôi nhận được một lỗi trong quá trình biên dịch mà góc không thể xác định mô-đun lớp trừu tượng thuộc về. Tôi không thể thêm nó vào mảng khai báo của NgModule, vậy cách tốt nhất để làm điều này là gì? Cấu trúc mã của tôi trông như thế này,Góc 2 angular-cli AOT khai báo lớp trừu tượng trong mô-đun?
//...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.
}
Lỗi trông giống như
ERROR in Cannot determine the module for class TutorialDirective in /test-app/src/app/tutorial/directive/tutorial.directive.ts!
My AppModule này:
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 sau khi một số lỗi, nếu tôi làm cho nó không trừu tượng và thêm nó vào khai báo nó hoạt động. Điều này có nghĩa là tôi không thể đánh dấu một lớp là trừu tượng? Đó dường như không đúng ...
Thêm mã cho mô-đun của bạn app.module.ts – Aravind
@Aravind ok. Tôi không thể thêm TutorialDirective vào mảng khai báo. Chỉ cần cho bạn biết. – Steveadoo
Ok, nếu tôi làm cho nó không trừu tượng và thêm nó vào khai báo nó hoạt động. Điều này có nghĩa là tôi không thể đánh dấu một lớp là trừu tượng? Điều đó có vẻ không đúng ... – Steveadoo