本文整理匯總了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);
});