Files
angular__angular/aio/src/app/custom-elements/element-registry.ts
T
ajitsinghkaler 5b33798796 feat(docs-infra): created new widget for events page (#36517)
Data in events page was hardcoded and it is manually moved in the table.

Created a new events widget which will automatically move past and upcoming
events from events.json (`aio/content/marketing/events.json`) file to the
relevant table in the events tab

PR Close #36517
2020-09-16 15:14:18 -07:00

66 lines
2.4 KiB
TypeScript

import { InjectionToken, Type } from '@angular/core';
import { LoadChildrenCallback } from '@angular/router';
// Modules containing custom elements must be set up as lazy-loaded routes (loadChildren)
// TODO(andrewjs): This is a hack, Angular should have first-class support for preparing a module
// that contains custom elements.
export const ELEMENT_MODULE_LOAD_CALLBACKS_AS_ROUTES = [
{
selector: 'aio-announcement-bar',
loadChildren: () => import('./announcement-bar/announcement-bar.module').then(m => m.AnnouncementBarModule)
},
{
selector: 'aio-api-list',
loadChildren: () => import('./api/api-list.module').then(m => m.ApiListModule)
},
{
selector: 'aio-contributor-list',
loadChildren: () => import('./contributor/contributor-list.module').then(m => m.ContributorListModule)
},
{
selector: 'aio-file-not-found-search',
loadChildren: () => import('./search/file-not-found-search.module').then(m => m.FileNotFoundSearchModule)
},
{
selector: 'aio-resource-list',
loadChildren: () => import('./resource/resource-list.module').then(m => m.ResourceListModule)
},
{
selector: 'aio-toc',
loadChildren: () => import('./toc/toc.module').then(m => m.TocModule)
},
{
selector: 'code-example',
loadChildren: () => import('./code/code-example.module').then(m => m.CodeExampleModule)
},
{
selector: 'code-tabs',
loadChildren: () => import('./code/code-tabs.module').then(m => m.CodeTabsModule)
},
{
selector: 'live-example',
loadChildren: () => import('./live-example/live-example.module').then(m => m.LiveExampleModule)
},
{
selector: 'aio-events',
loadChildren: () => import('./events/events.module').then(m => m.EventsModule)
}
];
/**
* Interface expected to be implemented by all modules that declare a component that can be used as
* a custom element.
*/
export interface WithCustomElementComponent {
customElementComponent: Type<any>;
}
/** Injection token to provide the element path modules. */
export const ELEMENT_MODULE_LOAD_CALLBACKS_TOKEN = new InjectionToken<Map<string, LoadChildrenCallback>>('aio/elements-map');
/** Map of possible custom element selectors to their lazy-loadable module paths. */
export const ELEMENT_MODULE_LOAD_CALLBACKS = new Map<string, LoadChildrenCallback>();
ELEMENT_MODULE_LOAD_CALLBACKS_AS_ROUTES.forEach(route => {
ELEMENT_MODULE_LOAD_CALLBACKS.set(route.selector, route.loadChildren);
});