當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript elements.createCustomElement函數代碼示例

本文整理匯總了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);
    }
  }
開發者ID:emartinez-usgs,項目名稱:earthquake-eventpages,代碼行數:34,代碼來源:shared.module.ts

示例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);
 }
開發者ID:liquidboy,項目名稱:GameOn,代碼行數:9,代碼來源:canvas.module.ts

示例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));
  }
開發者ID:Nodarii,項目名稱:material2,代碼行數:12,代碼來源:example-viewer.ts

示例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);
    }
  }
開發者ID:janjachacz,項目名稱:fireship.io,代碼行數:20,代碼來源:app.module.ts

示例5: constructor

  constructor(private injector: Injector) {
    const madeWithLoveElement = createCustomElement(MadeWithLoveComponent, { injector });

    customElements.define('made-with-love', madeWithLoveElement);
  }
開發者ID:jrsglobalpriv,項目名稱:made-with-love,代碼行數:5,代碼來源:made-with-love.module.ts

示例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}));
 }
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:6,代碼來源:app.ts

示例7: constructor

  constructor(private injector: Injector) {
    const tileElm = createCustomElement(DashboardTileComponent, { injector: this.injector });

    customElements.define('dashboard-tile', tileElm);
  }
開發者ID:yperrin,項目名稱:Experiments,代碼行數:5,代碼來源:dashboard-tile.module.ts

示例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);
 }
開發者ID:Smilehwj,項目名稱:pupupsample,代碼行數:6,代碼來源:app.component.ts

示例9: ngDoBootstrap

 ngDoBootstrap() {
   const elm = createCustomElement(AppComponent, { injector: this.injector });
   customElements.define('custom-element', elm);
 }
開發者ID:meeroslav,項目名稱:ngx-build-plus,代碼行數:4,代碼來源:app.module.ts

示例10: createCustomElement

 Object.keys(EXAMPLE_COMPONENTS).forEach(key => {
   const element = createCustomElement(EXAMPLE_COMPONENTS[key].component, {injector});
   customElements.define(key, element);
 });
開發者ID:OkBayat,項目名稱:material2,代碼行數:4,代碼來源:demo-module.ts


注:本文中的@angular/elements.createCustomElement函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。