在 Angular 5.1.0-beta.2 我有一个错误使用: ng serve --aot
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { AppComponent } from '../app.component';
import { DataModelService } from '@services/data-model.service';
import { BroadcasterService } from '@services/broadcaster.service';
import { GridManager } from '@services/grid.service';
import { ReactiveFormsModule } from '@angular/forms';
import { FormValidationService } from '@services/form-validation.service';
import { JitCompilerFactory } from "@angular/platform-browser-dynamic";
import { Compiler, COMPILER_OPTIONS, CompilerFactory, NgModule } from '@angular/core';
export function createCompiler(compilerFactory: CompilerFactory) {
return compilerFactory.createCompiler();
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, HttpClientModule, ReactiveFormsModule, HttpModule
],
providers: [DataModelService, BroadcasterService, FormValidationService, GridManager,
{ provide: COMPILER_OPTIONS, useValue: {}, multi: true },
{ provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS] },
{ provide: Compiler, useFactory: createCompiler, deps: [CompilerFactory] }],
bootstrap: [AppComponent]
})
export class AppModule { }
在我调用编译器的另一个文件中
@Component({ template: myTemplate })
class PhaseComponent implements OnInit { ngOnInit() {
}
}
@NgModule({
imports: [CommonModule, SharedModule],
declarations: [PhaseComponent],
schemas: [
NO_ERRORS_SCHEMA
]
})
class TemplateModule {
}
const mod = this.compiler.compileModuleAndAllComponentsSync(TemplateModule);
我的设置
Angular CLI: 1.5.4
Node: 6.9.5
OS: win32 x64
Angular: 5.1.0-beta.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.5.4
@angular/language-service: 5.0.3
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.1.7
typescript: 2.6.2
webpack: 3.8.1
请帮帮我。