我有一个 Angular (4.3.2) 应用程序,我想在其上执行 AOT 构建。应用程序是使用@angular/cli
. 我有两个组件ng generate
和一个模块,其中两个组件都包含在声明中:
import {PrivateComponent} from './private.component/private.component';
NgModule({
imports: [
// other imports
PrivateRoutingModule
],
declarations: [
...some other components,
PrivateComponent,
AppTopBarComponent
]
// other stuff
})
export class PrivateModule {}
私有组件也用于模块的路由:
const routes: Routes = [
{path: '', component: PrivateComponent, children: // other components}
]
@NgModule({
imports: [RouterModule.forChild(routes)] // this is the Angular built-in router module
})
export class PrivateRoutingModule {}
注意路由是如何在另一个模块中定义并导入到模板中使用的PrivateModule
。所以两者都被使用和声明。但是当我使用(我在 Windows 10 上)时,我收到以下错误消息:
. 我的文件与Angular AOT 构建指南中的完全相同。AppTopBarComponent
PrivateComponent's
"node_modules/.bin/ngc" -p tsconfig-aot.json
Cannot determine the module for class PrivateComponent in (path-to-project)/src/app/pages/private/private.component/private.component.ts! Add PrivateComponent to the NgModule to fix it.
Cannot determine the module for class AppTopBarComponent in (path-to-project)/src/app/pages/private/app.topbar.component.ts! Add AppTopBarComponent to the NgModule to fix it.
tsconfig-aot.json