Angularjs 如何克服AOT编译时的错误';无法确定类';的模块;?
JIT编译已经完成。但是,我决定使用 AOT编译。我得到以下错误:Angularjs 如何克服AOT编译时的错误';无法确定类';的模块;?,angularjs,angular,aot,angular2-aot,Angularjs,Angular,Aot,Angular2 Aot,JIT编译已经完成。但是,我决定使用 AOT编译。我得到以下错误: Cannot determine the module for class ProfileComponent Cannot determine the module for class ProfileComponent Cannot determine the module for class ProfileRESTService 我的应用程序由单个模块组成。同时,它有很多组件和服务。这些在单个@NgModule中描述。变
Cannot determine the module for class ProfileComponent
Cannot determine the module for class ProfileComponent
Cannot determine the module for class ProfileRESTService
我的应用程序由单个模块组成。同时,它有很多组件和服务。这些在单个@NgModule
中描述。变量MODULES
包含数组组件和服务,几乎没有@NgModule
,只有一个数组类
模块
...
import {ProfileModule} from './profile/module';
export const MODULES = [
...
ProfileModule
];
配置文件/模块.ts
...
import {ProfileComponent} from "./component/Profile/index";
import {ProfileRoute} from "./route/ProfileRoute/index";
import {ProfileRESTService} from "./service/ProfileRESTService";
export const ProfileModule = [
declarations: [
...
ProfileComponent
],
routes: [
...
ProfileRoute
],
providers: [
...
ProfileRESTService
]
]
app.module.ts
import {App} from './app.component';
import {routing} from "./app.routing";
import {MODULES} from "./module/modules";
let moduleDeclaration = {
declarations: [
App
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
BrowserModule,
routing,
FormsModule,
ReactiveFormsModule,
HttpModule,
]
bootstrap: [App]
};
for (let module of MODULES) {
if (!!module['declarations'] && module['declarations'] instanceof Array) {
for (let item of module['declarations']) {
moduleDeclaration.declarations.push(item)
}
}
if('routes'){...}
if('providers'){...}
if('imports'){...}
}
@NgModule(moduleDeclaration)
export class AppModule {}
我假设在AOT编译时,分析在
@NgModule
中传递的对象,在我的例子中,这个对象还没有准备好。重新编写将每个模块描述为@NgModule
的应用程序将很困难。如何使用动态可执行文件moduleDeclaration
解决问题?动态且提前。我认为那是不可能的。为什么你把所有的东西都放在一个NgModule里,而不是只制作几个NgModuleadviced@PierreDuc,开始时,我们决定所有组件都是全球性的。应用程序已经增长,很难描述每个模块的导出和导入。我认为最好的解决方案是编写一个脚本,将模块的描述收集到一个对象中,并在@NgModule
中传递该对象。也许这个问题与您的问题有关-