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


TypeScript platform-browser.DomSanitizer類代碼示例

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


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

示例1:

export const loadSvgResources = (ir: MdIconRegistry, ds: DomSanitizer) => {
    const imgDir = 'assets/img';
    const sidebarDir = `${imgDir}/sidebar`;
    const dayDir = `${imgDir}/days`;
    const avatarDir = `${imgDir}/avatar`;
    const iconDir = `${imgDir}/icons`;

    ir.addSvgIconSetInNamespace('avatars', ds.bypassSecurityTrustResourceUrl(`${avatarDir}/avatars.svg`));
    ir.addSvgIcon('unassigned', ds.bypassSecurityTrustResourceUrl(`${avatarDir}/unassigned.svg`));
    ir.addSvgIcon('day', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/day.svg`));
    ir.addSvgIcon('week', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/week.svg`))
    ir.addSvgIcon('month', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/month.svg`));
    ir.addSvgIcon('project', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/project.svg`));
    ir.addSvgIcon('projects', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/projects.svg`));
    ir.addSvgIcon('move', ds.bypassSecurityTrustResourceUrl(`${iconDir}/move.svg`));
    ir.addSvgIcon('add', ds.bypassSecurityTrustResourceUrl(`${iconDir}/add.svg`));
    ir.addSvgIcon('delete', ds.bypassSecurityTrustResourceUrl(`${iconDir}/delete.svg`));
    const days = [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
        11, 12, 13, 14, 15, 16, 17, 18, 
        19, 20, 21, 22, 23, 24, 25, 26, 
        27, 28, 29, 30, 31
    ]
    days.forEach(d => ir.addSvgIcon(`day${d}`, ds.bypassSecurityTrustResourceUrl(`${dayDir}/day${d}.svg`)));
}
開發者ID:zichenma,項目名稱:prodinator,代碼行數:25,代碼來源:svg.util.ts

示例2: constructor

 constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
   iconRegistry
       .addSvgIcon('thumb-up',
           sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'))
       .addSvgIconSetInNamespace('core',
           sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/core-icon-set.svg'))
       .registerFontClassAlias('fontawesome', 'fa');
 }
開發者ID:ravichandra480,項目名稱:material2,代碼行數:8,代碼來源:icon-demo.ts

示例3: transform

 public transform(
   value: any,
   type: string
 ): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
   switch (type) {
     case "html":
       return this.sanitizer.bypassSecurityTrustHtml(
         `${value}`.replace(/<p[^>]*>/g, "").replace(/<strong[^>]*>/g, "")
       );
     case "text":
       const span = document.createElement("span");
       span.innerHTML = value;
       return span.textContent || span.innerText;
     case "style":
       return this.sanitizer.bypassSecurityTrustStyle(value);
     case "script":
       return this.sanitizer.bypassSecurityTrustScript(value);
     case "url":
       return this.sanitizer.bypassSecurityTrustUrl(value);
     case "resourceUrl":
       return this.sanitizer.bypassSecurityTrustResourceUrl(value);
     default:
       throw new Error(`Invalid safe type specified: ${type}`);
   }
 }
開發者ID:strandls,項目名稱:biodiv-mobile,代碼行數:25,代碼來源:safe.pipe.ts

示例4: init

 public init() {
   this.iconRegistry.addSvgIcon(
       'add',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/note_add_48px.svg'));
   this.iconRegistry.addSvgIcon(
       'edit',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/edit_48px.svg'));
   this.iconRegistry.addSvgIcon(
       'delete',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/delete_forever_48px.svg'));
   this.iconRegistry.addSvgIcon(
       'calendar',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/calendar.svg'));
   this.iconRegistry.addSvgIcon(
       'time',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/time.svg'));
   this.iconRegistry.addSvgIcon(
       'search',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/search.svg'));
   this.iconRegistry.addSvgIcon(
       'title',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/title.svg'));
   this.iconRegistry.addSvgIcon(
       'logout',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logout.svg'));
   this.iconRegistry.addSvgIcon(
       'arrow_down',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/arrow_down.svg'));
   this.iconRegistry.addSvgIcon(
       'user',
       this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/user.svg'));
 }
開發者ID:KavvaP17,項目名稱:Angular_Global_Mentoring_Program_2018_Task2,代碼行數:32,代碼來源:init-icons.service.ts

示例5:

        this.streams.subscribe((streamsState: StreamState[]) => {
            console.log(streamsState);
            this.adjustContainer(this.ngRedux.getState().layout, streamsState);

           if (JSON.stringify(this.videoElement) !== JSON.stringify(this.domSanitizer.bypassSecurityTrustHtml(streamsState[this.videoContainerId].playerHtml))) {
                this.videoElement = this.domSanitizer.bypassSecurityTrustHtml(streamsState[this.videoContainerId].playerHtml);
           }
        });
開發者ID:Nightspeller,項目名稱:streamViewer,代碼行數:8,代碼來源:video-container.component.ts

示例6: transform

 transform(url) {
     if (url) {
         const urlWithParameters = this.addURLWithParameters(url);
         return this.sanitizer.bypassSecurityTrustResourceUrl(urlWithParameters);
     } else {
         return this.sanitizer.bypassSecurityTrustResourceUrl('');
     }
 }
開發者ID:dotCMS,項目名稱:core-web,代碼行數:8,代碼來源:safe-url.pipe.ts

示例7: transform

 transform(data: string): SafeHtml {
   if (data) {
     const md = new MarkdownIt();
     md.use(markdownItAttrs);
     return this.sanitizer.bypassSecurityTrustHtml(md.render(data));
   } else {
     return this.sanitizer.bypassSecurityTrustHtml('No Data');
   }
 }
開發者ID:daniru,項目名稱:blog,代碼行數:9,代碼來源:markdown.pipe.ts

示例8: transform

 public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
   switch (type) {
     case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
     case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
     case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
     case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
     case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
     default: throw new Error(`Invalid safe type specified: ${type}`);
   }
 }
開發者ID:macliems,項目名稱:JixyFront,代碼行數:10,代碼來源:safe-pipe.ts

示例9: getLevelStyle

  public getLevelStyle(): SafeStyle {
    let level = this.device.Level;

    let safeStyle: SafeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: 0%`);
    if(this.device.SwitchType === 'Dimmer' && (this.device.Data === 'On' || this.device.Data.startsWith('Set Level')))
      safeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: ${level}%`);
    else if(this.device.Data === 'On')
      safeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: 100%`);
    return safeStyle;
  }
開發者ID:robsonke,項目名稱:domotica-app,代碼行數:10,代碼來源:device.component.ts

示例10: serviceError

  serviceError(json: any) {
    const message = this.satinizer.sanitize(SecurityContext.HTML, json.message);
    const code = this.satinizer.sanitize(SecurityContext.HTML, json.code);

    const html = this.satinizer.bypassSecurityTrustHtml(`
      <div class="sn-title">Error</div>
      <div class="sn-content">
        ${message} </br>Code: ${code}
      </div>
  `);
    return this.html(html, 'error');
  }
開發者ID:sergiocosus,項目名稱:ventamatic.frontend,代碼行數:12,代碼來源:notify.service.ts


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