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


TypeScript core.RendererFactory2類代碼示例

本文整理匯總了TypeScript中@angular/core.RendererFactory2的典型用法代碼示例。如果您正苦於以下問題:TypeScript RendererFactory2類的具體用法?TypeScript RendererFactory2怎麽用?TypeScript RendererFactory2使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RendererFactory2類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: addInlineCodeToDocument

export function addInlineCodeToDocument(inlineCode: string, doc: Document, rendererFactory: RendererFactory2) {
  const renderType: RendererType2 = { id: '-1', encapsulation: ViewEncapsulation.None, styles: [], data: {} };
  const renderer = rendererFactory.createRenderer(doc, renderType);
  const script = renderer.createElement('script');
  renderer.setValue(script, inlineCode);
  renderer.insertBefore(doc.head, script, doc.head.firstChild);
}
開發者ID:jeffwhelpley,項目名稱:preboot,代碼行數:7,代碼來源:server-preboot.module.ts

示例2: constructor

 constructor(
     private componentFactoryResolver: ComponentFactoryResolver,
     private appRef: ApplicationRef,
     private injector: Injector,
     rendererFactory: RendererFactory2,
 ) {
     this.renderer = rendererFactory.createRenderer(null, null);
 }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:8,代碼來源:dynamic-popup.service.ts

示例3: constructor

 /**
  * Constructor
  * @param rendererFactory
  */
 constructor(private rendererFactory: RendererFactory2) {
   this.renderer = rendererFactory.createRenderer(null, null);
 }
開發者ID:BoykoAlex,項目名稱:spring-cloud-dataflow-ui,代碼行數:7,代碼來源:blocker.service.ts

示例4: Error

  /**
   * Inject the State into the bottom of the <head>
   */
  inject() {
    try {
      const document: any = this.state.getDocument();
      const transferStateString = JSON.stringify(this.toJson());
      const renderer = this.rendererFactory.createRenderer(document, {
        id: '-1',
        encapsulation: ViewEncapsulation.None,
        styles: [],
        data: {}
      });

      const head = document.head;
      if (head.localName !== 'head') {
        throw new Error(
          'Please have <head> as the first element in your document'
        );
      }

      const script = renderer.createElement('script');
      renderer.setValue(
        script,
        `window['TRANSFER_STATE'] = ${transferStateString}`
      );
      renderer.appendChild(head, script);
    } catch (e) {
      console.error(e);
    }
  }
開發者ID:sumanbh,項目名稱:amazon-clone,代碼行數:31,代碼來源:server-transfer-state.ts

示例5: inject

  /**
   * Inject the State into the bottom of the <head>
   */
  inject() {
    try {
      const document: any = this.state.getDocument();
      const transferStateString = JSON.stringify(this.toJson());
      const renderer = this.rendererFactory.createRenderer(document, {
        id: '-1',
        encapsulation: ViewEncapsulation.None,
        styles: [],
        data: {}
      });

      const body = document.body;

      const script = renderer.createElement('script');
      renderer.setValue(script, `window['TRANSFER_STATE'] = ${transferStateString}`);
      renderer.appendChild(body, script);
    } catch (e) {
      console.log('Failed to append TRANSFER_STATE to body');
      console.error(e);
    }
  }
開發者ID:BHARAT703,項目名稱:aspnetboilerplate-samples,代碼行數:24,代碼來源:server-transfer-state.ts

示例6: createRenderer

 private createRenderer(el: any, type: RendererType2, id: number) {
   this._renderStore.store(this._rendererFactory.createRenderer(el, type), id);
 }
開發者ID:Cammisuli,項目名稱:angular,代碼行數:3,代碼來源:renderer.ts


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