'SampleModule'はnpmパッケージなので、 'SampleModule'のファイルはnode_modulesフォルダ(プロジェクトルートパス)の下にあります。
まず次に、あなたのApp.module、インポートで 'SampleModule'
import { SampleModule } from '/path_to_node_modules/path_to_sample_module/';
@NgModule({
imports: [SampleModule],<== this line
})
export class AppModule{}
今あなたが直接 'SampleComponent' をインポートすることができますSampleModule
@NgModule({
declarations: [SampleComponet],
exports: [SampleComponet] <== this line
})
export class SampleModule{}
に次の行を追加してSampleComponetをエクスポートあなたのアプリケーション。インポートステートメントに従って帰る
import { SampleComponent } from '/path_to_node_modules/path_to_componet/';
{ path: 'sample', component: SampleComponent }
注: SampleModuleは独自のルーティングを持っており、それが
const routes: Routes = [~routings~]
@NgModule({
imports: [RouterModule.forChild(routes)],
declarations: [SampleComponet],
exports: [SampleComponet] <== this line
})
export class SampleModule{}
以下のように定義されている場合、アプリのルータに
{
path: 'sample',
loadChildren: './path_to_node_modules/path_to_sample_module/sample.module#SampleModule'
}
を次のコードを使用し、あなたのコードを提供することができます??。 –