Angular AOT编译错误“无法确定类组件的模块”
我有一个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
我实际上找到了一个解决方案.问题是PrivateComponent是在另一个文件中导入的,但没有使用,就像这样:
import { PrivateComponent } from '../private/private.component'; // not used anywhere 显然,ngc尝试链接所有内容,并被未使用的导入混淆 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |