Angular 如何从库中导入零部件(在nrwl/nx中,带角度)
我想将我的Angular 如何从库中导入零部件(在nrwl/nx中,带角度),angular,typescript,nrwl,nrwl-nx,Angular,Typescript,Nrwl,Nrwl Nx,我想将我的PageNotFoundComponent从我的ui组件库导入我的应用程序路由器 当我将UiComponentsModule导入我的AppModule并使用模板中的组件时,一切正常,但导入es6表示法中的组件失败 /libs/ui-components/src/lib/ui-components.module.ts import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/cor
PageNotFoundComponent
从我的ui组件库导入我的应用程序路由器
当我将UiComponentsModule
导入我的AppModule
并使用模板中的组件时,一切正常,但导入es6表示法中的组件失败
/libs/ui-components/src/lib/ui-components.module.ts
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ContactCardComponent } from './contact-card/contact-card.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { WhiteLabelFooterComponent } from './white-label-footer/white-label-footer.component';
import { WhiteLabelHeaderComponent } from './white-label-header/white-label-header.component';
@NgModule({
declarations: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
exports: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
imports: [CommonModule],
})
export class UiComponentsModule {}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NotFoundComponent } from 'libs/ui-components/src/lib/not-found/not-found.component';
const routes: Routes = [
{
path: '**',
component: NotFoundComponent,
},
];
@NgModule({
exports: [RouterModule],
imports: [RouterModule.forRoot(routes)],
})
export class AppRoutingModule {}
/apps/myApp/src/app/app-routing.module.ts
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ContactCardComponent } from './contact-card/contact-card.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { WhiteLabelFooterComponent } from './white-label-footer/white-label-footer.component';
import { WhiteLabelHeaderComponent } from './white-label-header/white-label-header.component';
@NgModule({
declarations: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
exports: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
imports: [CommonModule],
})
export class UiComponentsModule {}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NotFoundComponent } from 'libs/ui-components/src/lib/not-found/not-found.component';
const routes: Routes = [
{
path: '**',
component: NotFoundComponent,
},
];
@NgModule({
exports: [RouterModule],
imports: [RouterModule.forRoot(routes)],
})
export class AppRoutingModule {}
从'libs/ui-components/src/lib/not-found/not-found.component'导入{NotFoundComponent}代码>我得到林特错误:
库导入必须以@frontend开头/
(nx强制模块边界)tslint(1)来自的子模块导入路径
这个包裹是不允许的;改为从根目录导入
(无子模块导入)tslint(1)模块“libs”未列为
package.json中的依赖项(无隐式依赖项)tslint(1)
当我将导入从'@frontend/ui-components'更改为import{NotFoundComponent}时代码>然后我得到错误:
模块
“../../../../../../../../../../../Users/LeitgebF/Projects/KLAITONWeb/frontend/libs/ui-components/src”
没有导出的成员“NotFoundComponent”.ts(2305)
那么如何直接从Nx中的库导入组件呢?我还必须将所需组件添加到桶文件中。下面是github回购支持部门直接给出的答案:
我没有倒立,为什么我需要角度模块,但我创建了它,并将其他组件导出到桶文件中。您找到了为什么导入ngModules的答案了吗?我和你在github有同样的问题。