嵌套子路由中延迟加载的问题,角度。无法访问视图

时间:2020-09-04 21:49:40

标签: angular routes angular2-routing

const table1 = await page.$$eval('table:nth-child(3) tbody', tbodys => tbodys.map((tbody) => {
  // add logic here!
  let parsedTable = '';
  let extractedTRs = tbody.match(/<tr>(.*?)<\/tr>/g); // find a way to deconstruct this or regex. what is the type of tbody?
  extractedTRs.map( tr => {
  const tr= str.match(/<td>(.*?)<\/td>/g); //this should return an array...someone check me :)
  parsedTable += `tr[0]:'${tr[1]}' \\n`); 
}
  
  return parsedTable;
}));

从此代码中,我无法加载ProtocolloModule。当我从路由中写“ configurazione / protocollo”时,我陷入了“ configurazione”路径中。我该如何解决? 如果我在第二个孩子中插入loadModule,那么一切都很好。如何使它以这种方式工作?

2 个答案:

答案 0 :(得分:0)

const routes: Routes = [
  {
    path: '',
        component: ProtocolloGestioneComponent,
        data: { breadcrumbs: 'Protocollo' },
    children: [
      {
        path: 'crea',
        component: ProtocolloCensimentoSidenavComponent,
        canDeactivate : [CanDeactivateGuard]
      }
    ],  
  },
  { path: '**', redirectTo: '' }
]

@NgModule({
  declarations: [],
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class ProtocolloRoutingModule { }

这是协议的路由,我无法理解缺少的内容,或者尚未放入嵌套方式。

答案 1 :(得分:0)

我设法使它起作用。 组件配置模板中没有。现在,我遇到另一个问题,在配置/协议中,我同时拥有配置模板和协议模板,就好像指令不会从视图中切换一样