使用安全管道的多个MatIconRegistry

时间:2018-07-07 09:54:21

标签: angular angular-material

请您帮我下面的代码,以便我可以动态注册多个svg并动态使用domsanitizer

import { Component, OnInit } from '@angular/core'
import { DomSanitizer } from '@angular/platform-browser'
import { MatIconRegistry } from '@angular/material'

@Component({
   selector: 'oc-logo',
   template: `<mat-icon svgIcon="theater"></mat-icon>`,
   styles: [''],
})
export class LogoComponent implements OnInit {
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
  iconRegistry.addSvgIcon(
                'theater',
sanitizer.bypassSecurityTrustResourceUrl('../../../.././assets/logo/theater.svg')
)
}

ngOnInit() {}
}

0 个答案:

没有答案