Я нашел это как лучший способ: 1. в app-routing.module.ts я установил логическое свойство для индексации данных с именем isIndexSliderDialog и установил его на значение
{
path: 'insuranceKindSample',
component: InsuranceKindIndexSampleComponent,
data: { title: ' آزمایش ثبت اطلاعات نوع بیمه', icon: 'fa-bar-chart', showInMenu: true, position: 'parent' },
children: [
{
path: 'master-dialog',
component: InsuranceKindMasterDialogComponent,
data: { title: 'Master-dialog', icon: 'fa-bar-chart', showInMenu: false },
children: [
{
path: 'index',
component: InsuranceKindIndexDialogComponent,
data: { title: 'Index', icon: 'fa-bar-chart', showInMenu: false, isIndexSliderDialog: true }
},
{
path: 'add',
component: InsuranceKindCreateSampleComponent,
data: { title: 'Add', icon: 'fa-bar-chart', showInMenu: false }
},
{
path: 'edit',
component: InsuranceKindEditSampleComponent,
data: { title: 'Edit', icon: 'fa-bar-chart', showInMenu: false }
},
]
},
]
},
затем в Insurance-Kind-Master-Dialog.Component.ts я использовал ловушки жизненного цикла, ngAfterViewInit () для проверки компонента, который загружается в router-outlet и получает свойство, которое я установил в app-routing.module.ts
ngAfterViewInit() {
this.isIndexSliderDialog = this.route.firstChild.snapshot.data.isIndexSliderDialog;
this.router.events.subscribe(e => {
this.isIndexSliderDialog = this.route.firstChild.snapshot.data.isIndexSliderDialog;
});
3.in Insurance-Kind-Master-Dialog.Component.html Я использовал ngClass, чтобы установить class1 для индекса и class2 для других маршрутов:
<div [ngClass]="isIndexSliderDialog== true ? 'class1' : 'class2'">
<router-outlet></router-outlet>
</div>