填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

ANALYZE_FOR_ENTRY_COMPONENTS

可用于创建虚拟提供者的 DI 令牌,该虚拟提供者将基于其 useValue 属性值填充组件和 NgModule 的 entryComponents 字段。useValue 值中引用的所有组件(无论是直接还是在嵌套数组还是在映射表中)都将添加到 entryComponents 属性。

A DI token that you can use to create a virtual provider that will populate the entryComponents field of components and NgModules based on its useValue property value. All components that are referenced in the useValue value (either directly or in a nested array or map) are added to the entryComponents property.

已弃用: Since 9.0.0. With Ivy, this property is no longer necessary.

从 9.0.0 开始。使用 Ivy,不再需要此属性。

      
      const ANALYZE_FOR_ENTRY_COMPONENTS: InjectionToken<any>;
    

使用说明

以下示例演示了路由器如何基于引用组件的路由器配置设置 entryComponents 字段。

The following example shows how the router can populate the entryComponents field of an NgModule based on a router configuration that refers to components.

      
      // helper function inside the router
function provideRoutes(routes) {
  return [
    {provide: ROUTES, useValue: routes},
    {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
  ];
}

// user code
let routes = [
  {path: '/root', component: RootComp},
  {path: '/teams', component: TeamsComp}
];

@NgModule({
  providers: [provideRoutes(routes)]
})
class ModuleWithRoutes {}