在标签页下显示内容,而不是跳转到新页面。

huangapple go评论47阅读模式
英文:

Display content underneath tab rather than going to new page

问题

在我的应用程序的一个页面中,我有一个选项卡,设置如下:

<igx-tab-item>
  <igx-tab-header [routerLink]="['projectsor', libraryId]">
    <span igxTabHeaderLabel>查看项目SOR</span>
  </igx-tab-header>
</igx-tab-item>

目前,该选项卡会带您转到一个新页面,但我想要的是在该选项卡下方显示数据,但我不确定如何实现。我知道使用router-outlet可能是最好的选择,但我不确定哪里出错了。

我已经更改为以下方式:

<igx-tab-item>
  <igx-tab-header>
    <span igxTabHeaderLabel>查看项目SOR</span>
  </igx-tab-header>
  <igx-tab-content>
    <router-outlet></router-outlet>
  </igx-tab-content>
</igx-tab-item>

在我的路由文件中,我有以下内容:

const routes: Routes = [
  { path: 'detail', component: ProjectDetailComponent},
  { path: 'detail/:id', component: ProjectDetailComponent},
  { path: 'detail/:id/projectsor/:libraryId', component: LibraryDetailComponent,
    children: [
      {path: '', component: LibrarySetupComponent},
      {path: 'disciplines', component: DisciplineListComponent},
      {path: 'jointdisciplines', component: JointDisciplineListComponent},
      {path: 'materials', component: MaterialListComponent},
      {path: 'weights', component: WeightItemListComponent},
      {path: 'schedules/:disciplineId', component: ScheduleListComponent},
      {path: 'r6/:disciplineId/:scheduleId', component: R6ItemListComponent},
      {path: 'r7/:disciplineId/:scheduleId', component: R7ItemListComponent},
    ]},
  { path: '', component: ProjectListComponent }
];

我想要显示的内容来自:

path: 'detail/:id/projectsor/:libraryId', component: LibraryDetailComponent,

你如何让router-outlet知道我希望它显示什么呢?

Hope this helps!

英文:

In one of the pages of my application I've got tabs with one setup like so:

        <igx-tab-item>
          <igx-tab-header [routerLink]="['projectsor', libraryId]">
            <span igxTabHeaderLabel>View Project SOR</span>
          </igx-tab-header>
        </igx-tab-item>

At the moment that tab will take take you to a new page, what I am trying to change however is to just have the data displayed underneath that tab but I am not sure how I can go about this. I am aware that using router-outlet would be my best bet but I'm not sure where I'm going wrong with this.

I have changed it to like so:

        <igx-tab-item>
          <igx-tab-header>
            <span igxTabHeaderLabel>View Project SOR</span>
          </igx-tab-header>
          <igx-tab-content>
            <router-outlet></router-outlet>
          </igx-tab-content>
        </igx-tab-item>

and in my routing file I have the following:

const routes: Routes = [
  { path: 'detail', component: ProjectDetailComponent},
  { path: 'detail/:id', component: ProjectDetailComponent},
  { path: 'detail/:id/projectsor/:libraryId', component: LibraryDetailComponent,
    children: [
    {path: '', component: LibrarySetupComponent},
    {path: 'disciplines', component: DisciplineListComponent},
    {path: 'jointdisciplines', component: JointDisciplineListComponent},
    {path: 'materials', component: MaterialListComponent},
    {path: 'weights', component: WeightItemListComponent},
    {path: 'schedules/:disciplineId', component: ScheduleListComponent},
    {path: 'r6/:disciplineId/:scheduleId', component: R6ItemListComponent},
    {path: 'r7/:disciplineId/:scheduleId', component: R7ItemListComponent},
  ]},
  { path: '', component: ProjectListComponent }
];

The content I am wanting to show is from:

path: 'detail/:id/projectsor/:libraryId', component: LibraryDetailComponent,

how can I let the router-outlet know what I am wanting it to show?

答案1

得分: 0

这是您要翻译的部分:

Found out how to fix my error, was more sorting the paths rather than creating a secondary outlet. In my routing file I just had to update it like so:

在修复错误时发现,更多是对路径进行排序,而不是创建次要出口。在我的路由文件中,我只需要像这样更新它:

const routes: Routes = [
{ path: 'detail', component: ProjectDetailComponent},
{ path: 'detail/:id', component: ProjectDetailComponent,
children: [
{ path: 'projectsor/:libraryId', component: LibraryDetailComponent,
children: [
{path: '', component: LibrarySetupComponent},
{path: 'disciplines', component: DisciplineListComponent},
{path: 'jointdisciplines', component: JointDisciplineListComponent},
{path: 'materials', component: MaterialListComponent},
{path: 'weights', component: WeightItemListComponent},
{path: 'schedules/:disciplineId', component: ScheduleListComponent},
{path: 'r6/:disciplineId/:scheduleId', component: R6ItemListComponent},
{path: 'r7/:disciplineId/:scheduleId', component: R7ItemListComponent}
]}
]},
{ path: '', component: ProjectListComponent }
];

and then in the html do:

然后在HTML中执行:

<igx-tab-item routerLinkActive #rlaSOR="routerLinkActive" [selected]="rlaSOR.isActive">
<igx-tab-header [routerLink]="['projectsor', libraryId]">
View Project SOR




英文:

Found out how to fix my error, was more sorting the paths rather than creating a secondary outlet. In my routing file I just had to update it like so:

const routes: Routes = [
  { path: &#39;detail&#39;, component: ProjectDetailComponent},
  { path: &#39;detail/:id&#39;, component: ProjectDetailComponent,
    children: [
      { path: &#39;projectsor/:libraryId&#39;, component: LibraryDetailComponent,
        children: [
        {path: &#39;&#39;, component: LibrarySetupComponent},
        {path: &#39;disciplines&#39;, component: DisciplineListComponent},
        {path: &#39;jointdisciplines&#39;, component: JointDisciplineListComponent},
        {path: &#39;materials&#39;, component: MaterialListComponent},
        {path: &#39;weights&#39;, component: WeightItemListComponent},
        {path: &#39;schedules/:disciplineId&#39;, component: ScheduleListComponent},
        {path: &#39;r6/:disciplineId/:scheduleId&#39;, component: R6ItemListComponent},
        {path: &#39;r7/:disciplineId/:scheduleId&#39;, component: R7ItemListComponent}
    ]}
]},
  { path: &#39;&#39;, component: ProjectListComponent }
];

and then in the html do:

        &lt;igx-tab-item routerLinkActive #rlaSOR=&quot;routerLinkActive&quot; [selected]=&quot;rlaSOR.isActive&quot;&gt;
          &lt;igx-tab-header [routerLink]=&quot;[&#39;projectsor&#39;, libraryId]&quot;&gt;
            &lt;span igxTabHeaderLabel&gt;View Project SOR&lt;/span&gt;
          &lt;/igx-tab-header&gt;
          &lt;igx-tab-content&gt;
            &lt;router-outlet&gt;&lt;/router-outlet&gt;
          &lt;/igx-tab-content&gt;
        &lt;/igx-tab-item&gt;

huangapple
  • 本文由 发表于 2023年4月10日 23:35:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75978473.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定