本文整理汇总了TypeScript中@angular/elements.createCustomElement函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createCustomElement函数的具体用法?TypeScript createCustomElement怎么用?TypeScript createCustomElement使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createCustomElement函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(public injector: Injector) {
// shakemap-station constructor will be an HTMLElement if it's not
// registered yet
const stationConst = document.createElement('shakemap-station').constructor;
if (stationConst === HTMLElement) {
// shakemap-station element is not yet registered
const station = createCustomElement(StationComponent, { injector });
customElements.define('shakemap-station', station);
}
// create dyfi-response-popup
const dyfiPopupConst = document.createElement('dyfi-response').constructor;
if (dyfiPopupConst === HTMLElement) {
// dyfi popup element is not yet registered
const dyfiPopup = createCustomElement(DyfiResponsePopupComponent, {
injector
});
customElements.define('dyfi-response', dyfiPopup);
}
// create finite-fault map popup
const ffPopupConst = document.createElement('finite-fault-map-popup')
.constructor;
if (ffPopupConst === HTMLElement) {
// finite fault popup is not yet registered
const ffPopup = createCustomElement(FiniteFaultMapPopupComponent, {
injector
});
customElements.define('finite-fault-map-popup', ffPopup);
}
}
示例2: createCustomElement
register<T>(moduleRef: NgModuleRef<any>, component: Type<T>) {
//console.log(moduleRef);
const componentFactory = moduleRef.componentFactoryResolver.resolveComponentFactory<T>(component);
//console.log(componentFactory);
// const ngElementConfig = getConfigFromComponentFactory(componentFactory, moduleRef.injector);
const ngElementCtor = createCustomElement(component, { injector: moduleRef.injector });
//console.log(ngElementCtor);
customElements.define(componentFactory.selector, ngElementCtor);
}
示例3: ngOnInit
ngOnInit() {
let exampleElementCtor = customElements.get(this.id);
if (!exampleElementCtor) {
exampleElementCtor =
createCustomElement(EXAMPLE_COMPONENTS[this.id].component, {injector: this._injector});
customElements.define(this.id, exampleElementCtor);
}
this._elementRef.nativeElement.appendChild(new exampleElementCtor(this._injector));
}
示例4: ngDoBootstrap
ngDoBootstrap() {
const elements: any[] = [
[GoogleLoginComponent, 'google-login'],
[ThemeBtnComponent, 'theme-btn'],
[LazyComponent, 'lazy-content'],
[RouteLoaderComponent, 'route-loader'],
[UserProfileComponent, 'user-profile'],
[AlgoliaSearchComponent, 'algolia-search'],
[AlgoliaButtonComponent, 'algolia-button'],
[VideoPlayerComponent, 'video-player'],
[SlackMirrorComponent, 'slack-mirror'],
[TogglerComponent, 'menu-toggler'],
[NotificationComponent, 'app-notification']
];
for (const [component, name] of elements) {
const el = createCustomElement(component, { injector: this.injector });
customElements.define(name, el);
}
}
示例5: constructor
constructor(private injector: Injector) {
const madeWithLoveElement = createCustomElement(MadeWithLoveComponent, { injector });
customElements.define('made-with-love', madeWithLoveElement);
}
示例6: constructor
constructor(private injector: Injector) {
customElements.define('hello-world-el', createCustomElement(HelloWorldComponent, {injector}));
customElements.define(
'hello-world-shadow-el', createCustomElement(HelloWorldShadowComponent, {injector}));
customElements.define('test-card', createCustomElement(TestCardComponent, {injector}));
}
示例7: constructor
constructor(private injector: Injector) {
const tileElm = createCustomElement(DashboardTileComponent, { injector: this.injector });
customElements.define('dashboard-tile', tileElm);
}
示例8: constructor
constructor(private injector: Injector, public popup: PopupService) {
// on init, convert PopupComponent to a custom element
const PopupElement = createCustomElement(PopupComponent, { injector: this.injector });
// register the custom element with the browser.
customElements.define('popup-element', PopupElement);
}
示例9: ngDoBootstrap
ngDoBootstrap() {
const elm = createCustomElement(AppComponent, { injector: this.injector });
customElements.define('custom-element', elm);
}
示例10: createCustomElement
Object.keys(EXAMPLE_COMPONENTS).forEach(key => {
const element = createCustomElement(EXAMPLE_COMPONENTS[key].component, {injector});
customElements.define(key, element);
});