[英]Difficulty to open component from another module
我的例子是:州和市。
我想在視圖城市上創建一個下拉列表,其中包含一個固定項目,例如:“添加新項目”。 當點擊此項時,模型會出現狀態組件以添加新狀態。
我已經在 CityModule 中導入了 StateModule,但是當我點擊打開城市的任何視圖時,它會打開狀態而不是城市......(下圖)
city.module.ts
@NgModule({
imports: [ StateModule, ...],
declarations: [ ... ]
...
})
Cidade = 城市 | Estado = 狀態 | 卡斯特羅 = 注冊
編輯
我還沒有做下拉列表
<button (click)="modal()">Click Here</button>
modal() {
this.ngbModalService.open(AddStateComponent,{size: 'lg'});
}
路線
export const CityRouterConfig: Routes =
[
{
path: '', component: CityComponent,
data: {
title: 'City',
urls: [{ title: 'Cities', url: '/cidade' }, { title: 'City' }]
},
children: [
...,
{ path: 'add', component: AddCityComponent,
data: {
title: 'City',
urls: [{ title: 'Cities', url: '/cidade' }, { title: 'City' }]
}
}
]
}
]
關於重復
我的open
是一個component
。
該鏈接帶有"string" html
。
我不明白鏈接以及我必須做什么才能解決我的問題......
我用共享模塊解決了
city.module.ts
@NgModule({
imports: [ SharedModule, ...],
declarations: [ ... ]
...
})
狀態.module.ts
@NgModule({
imports: [ SharedModule, ...],
declarations: [ ... ]
...
})
共享模塊.ts
@NgModule({
imports: [
],
declarations: [
AddStateComponent
],
providers: [
],
bootstrap: [
],
exports: [
AddStateComponent
]
})
export class SharedModule { }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.