在空路径上加载不同组件的角形路线

时间:2020-03-04 16:59:11

标签: angular

我的项目结构是这样的:

/**********************************************************************************
Function Name: rtcCalcYearWeek
Description  : Function to calculate the working week of the year (changing on a Monday)
Arguments    : IN  iYear - The year 2000...
               IN  iMonth - The month 1..12
               IN  iDay - The day 1..31
               IN  iWeekDay - The week day 0 = Monday ... 6 = Sunday
Return Value : The year week 1..52
***********************************************************************************/
int rtcCalcYearWeek(int iYear, int iMonth, int iDay, int iWeekDay)
{
    int iLeap = 0;
    static const int ppiYearDays[2][13] =
    {
         /* Normal year */
         {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},
         /* Leap year */
         {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
    };
    /* Check for leap year */
    if (((iYear % 4) == 0) && (((iYear % 100) != 0) || ((iYear % 400) == 0)))
    {
        iLeap = 1;
    }
    /* Calculate the year week */
    return (((ppiYearDays[iLeap][iMonth] + iDay) - (iWeekDay + 7) % 7 + 7) / 7) + 1;
}
/***********************************************************************************
End of function  rtcCalcYearWeek
***********************************************************************************/

/**********************************************************************************
* Function Name: rtcCalcWeekDay
* Description  : Function to calculate the week day for a given date from 2000
*                to 2099.
* Arguments    : IN  iDay - The day 1..31
*                IN  iMonth - The month 1..12
*                IN  iYear - The year 2000..2099
* Return Value : The weekday 0 = Monday ... 6 = Sunday
***********************************************************************************/
int rtcCalcWeekDay(int iDay, int iMonth, int iYear)
{
    if (iMonth < 3)
    {
        iMonth += 12;
        iYear -= 1;
    }
    return (iDay + (2 * iMonth) + (6 * (iMonth + 1) / 10) + iYear 
            + (iYear / 4)- (iYear / 100) + (iYear / 400)) % 7;
}
/***********************************************************************************
End of function  rtcCalcWeekDay
***********************************************************************************/

每个文件夹都包含一个模块和一个组件(auth除外)。我的想法是让每条路线都由其模块分隔开,然后再重定向到/ dashboard。

在app.module内部,我有以下路线:

app/
--main/
  --dashboard/
    --home/
    --admin/
      --users/

在dashboard.module内部,我有这个:

{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: '**', redirectTo: 'dashboard' }

内部管理模块:

{
    path: '',
    canActivate: [AuthGuard],
    component: DashboardComponent,
    children: [
        { path: 'dashboard', component: HomeComponent },
        { path: 'admin', loadChildren: './admin/admin.module#AdminModule' }
    ]
}

在users.module内部:

{ path: 'users', loadChildren: './users/users.module#UsersModule' }

现在一切正常就可以了,{ path: '', component: UsersComponent } 加载UsersComponent,而/admin/users加载DashboardComponent。但是,当我尝试转到/dashboard时,而不是加载DashboardComponent,而是加载了UsersComponent。为什么会这样?

1 个答案:

答案 0 :(得分:0)

如何切换子路径的顺序

{
    path: '',
    canActivate: [AuthGuard],
    component: DashboardComponent,
    children: [
        { path: 'admin', loadChildren: './admin/admin.module#AdminModule' },
        { path: 'dashboard', component: HomeComponent }

    ]
}

因为那没有用。尝试导入模块的顺序。似乎通过重定向到仪表板选择了UserModule的空白路径。确保您的RouterModule导入到您的app.module中是最后一个