@angular/platform-browser#DomSanitizer TypeScript Examples

The following examples show how to use @angular/platform-browser#DomSanitizer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: platformBrowser.spec.ts    From ngx-dynamic-hooks with MIT License 6 votes vote down vote up
class MockDomSanitizer implements DomSanitizer {
  bypassSecurityTrustHtml(value: string): SafeHtml {
    throw new Error('Method not implemented.');
  }

  bypassSecurityTrustStyle(value: string): SafeStyle {
    throw new Error('Method not implemented.');
  }

  bypassSecurityTrustScript(value: string): SafeScript {
    throw new Error('Method not implemented.');
  }

  bypassSecurityTrustUrl(value: string): SafeUrl {
    throw new Error('Method not implemented.');
  }

  bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl {
    throw new Error('Method not implemented.');
  }

  sanitize(context: any, content: string): string {
    return content;
  }
}
Example #2
Source File: safe-url.pipe.spec.ts    From mylog14 with GNU General Public License v3.0 6 votes vote down vote up
describe('SafeUrlPipe', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [BrowserModule],
    });
  });
  it('create an instance', () => {
    const domSanitizer = TestBed.get(DomSanitizer);
    const pipe = new SafeUrlPipe(domSanitizer);
    expect(pipe).toBeTruthy();
  });
});
Example #3
Source File: blog-post-details.ts    From ionic-doctor-online with MIT License 6 votes vote down vote up
constructor(public navCtrl: NavController,
              public navParams: NavParams,
              private domSanitizer: DomSanitizer,
              private loadingCtrl: LoadingController) {
    if (this.navParams.data != undefined) {
      this.item = this.navParams.data;
      this.title = this.item.title.substring(0, 25);
    }
  }
Example #4
Source File: about.component.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
public constructor(
    public wowUpService: WowUpService,
    public electronService: ElectronService,
    private _sessionService: SessionService,
    private _patchNotesService: PatchNotesService,
    private _sanitizer: DomSanitizer,
    private _linkService: LinkService
  ) {
    this.changeLogs = this._patchNotesService.changeLogs;
    const tabIndexSub = this._sessionService.selectedHomeTab$
      .pipe(
        filter((newTabIndex) => newTabIndex === this.tabIndex),
        map(() => {
          window.getSelection()?.empty();
        })
      )
      .subscribe();

    this._subscriptions.push(tabIndexSub);
  }
Example #5
Source File: app.component.ts    From svg-path-editor with Apache License 2.0 6 votes vote down vote up
constructor(
    matRegistry: MatIconRegistry,
    sanitizer: DomSanitizer,
    public cfg: ConfigService,
    private storage: StorageService
  ) {
    (window as any).browserComputePathBoundingBox = browserComputePathBoundingBox;
    for (const icon of ['delete', 'logo', 'more', 'github', 'zoom_in', 'zoom_out', 'zoom_fit', 'sponsor']) {
      matRegistry.addSvgIcon(icon, sanitizer.bypassSecurityTrustResourceUrl(`./assets/${icon}.svg`));
    }
    this.parsedPath = new Svg('');
    this.reloadPath(this.rawPath, true);
  }
Example #6
Source File: image-crop.component.ts    From ASW-Form-Builder with MIT License 6 votes vote down vote up
constructor(
        private cropService: CropService,
        private cropperPositionService: CropperPositionService,
        private loadImageService: LoadImageService,
        private sanitizer: DomSanitizer,
        private cd: ChangeDetectorRef
    ) {
        this.reset();
    }
Example #7
Source File: period-selector.component.ts    From budget-angular with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    periodService: PeriodService,
    iconRegistry: MatIconRegistry,
    sanitizer: DomSanitizer
  ) {
    iconRegistry.addSvgIcon(
      "left",
      sanitizer.bypassSecurityTrustResourceUrl("assets/left.svg")
    );
    iconRegistry.addSvgIcon(
      "right",
      sanitizer.bypassSecurityTrustResourceUrl("assets/right.svg")
    );

    this.month = periodService.getCurrentPeriod().month;
    this.year = periodService.getCurrentPeriod().year;
  }
Example #8
Source File: credentialdetails.page.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(
    public events: Events,
    public route: ActivatedRoute,
    private router: Router,
    public zone: NgZone,
    private translate: TranslateService,
    private didService: DIDService,
    public theme: GlobalThemeService,
    public actionSheetController: ActionSheetController,
    public profileService: ProfileService,
    private globalIntentService: GlobalIntentService,
    private globalPopupService: GlobalPopupService,
    private globalNavService: GlobalNavService,
    private globalNativeService: GlobalNativeService,
    private didDocumentsService: DIDDocumentsService,
    private authService: AuthService,
    private credentialsService: CredentialsService,
    private sanitizer: DomSanitizer,
    private globalCredentialTypesService: GlobalCredentialTypesService
  ) {
    this.init();
  }
Example #9
Source File: fy-view-attachment.component.ts    From fyle-mobile-app with MIT License 6 votes vote down vote up
// max params shouldnt effect constructors
  constructor(
    private modalController: ModalController,
    private popoverController: PopoverController,
    private sanitizer: DomSanitizer,
    private popupService: PopupService,
    private loaderService: LoaderService,
    private fileService: FileService
  ) {}
Example #10
Source File: safe.pipe.spec.ts    From mns with MIT License 6 votes vote down vote up
describe('SafePipe', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [BrowserModule],
    });
  });

  it('create an instance', () => {
    const domSanitizer = TestBed.inject(DomSanitizer);
    const pipe = new SafePipe(domSanitizer);
    expect(pipe).toBeTruthy();
  });
});
Example #11
Source File: model-settings.component.ts    From EDA with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(
    private formBuilder: FormBuilder,
    private sidebarService: SidebarService,
    private dataSourceService: DataSourceService,
    private dashboardService: DashboardService,
    private sanitizer: DomSanitizer,
    private alertService: AlertService) {

    this.exportModelForm = this.formBuilder.group({
      model: [null, Validators.required]
    });

    this.dashBoardForm = this.formBuilder.group({
      dashboard: [null, Validators.required]
    });

  }
Example #12
Source File: app.component.ts    From capture-lite with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    private readonly platform: Platform,
    private readonly collectorService: CollectorService,
    private readonly iconRegistry: MatIconRegistry,
    private readonly sanitizer: DomSanitizer,
    private readonly capacitorFactsProvider: CapacitorFactsProvider,
    private readonly webCryptoApiSignatureProvider: WebCryptoApiSignatureProvider,
    private readonly captureService: CaptureService,
    private readonly cameraService: CameraService,
    private readonly errorService: ErrorService,
    notificationService: NotificationService,
    pushNotificationService: PushNotificationService,
    langaugeService: LanguageService,
    diaBackendAuthService: DiaBackendAuthService,
    diaBackendNotificationService: DiaBackendNotificationService,
    uploadService: DiaBackendAssetUploadingService
  ) {
    notificationService.requestPermission();
    pushNotificationService.register();
    langaugeService.initialize();
    diaBackendAuthService.initialize$().pipe(untilDestroyed(this)).subscribe();
    uploadService.initialize$().pipe(untilDestroyed(this)).subscribe();
    diaBackendNotificationService
      .initialize$()
      .pipe(untilDestroyed(this))
      .subscribe();
    this.initializeApp();
    this.restoreAppState();
    this.initializeCollector();
    this.registerIcon();
  }
Example #13
Source File: avatar-cropper.component.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
constructor(
    public imageService: ImageService,
    private sanitizer: DomSanitizer,
    protected overlay: Overlay,
    protected router: Router,
    protected destroyer: Destroyer,
  ) {
    super();
  }
Example #14
Source File: customer.detail.component.ts    From digital-bank-ui with Mozilla Public License 2.0 6 votes vote down vote up
constructor(
    private route: ActivatedRoute,
    private router: Router,
    private store: Store<fromCustomers.State>,
    private customerService: CustomerService,
    private dialogService: NbDialogService,
    private notificationService: NotificationService,
    private domSanitizer: DomSanitizer,
  ) {}
Example #15
Source File: app.component.ts    From ewelink-web-ui with MIT License 6 votes vote down vote up
constructor(private matIconRegistry: MatIconRegistry, private domSanitizer: DomSanitizer, private themeService: ThemeService) {

    this.themeService.initTheme();

    this.matIconRegistry.addSvgIcon(
      "github",
      this.domSanitizer.bypassSecurityTrustResourceUrl('/assets/github.svg')
    );

    this.matIconRegistry.addSvgIcon(
      'preview',
      this.domSanitizer.bypassSecurityTrustResourceUrl('/assets/preview.svg')
    );

  }
Example #16
Source File: app.component.ts    From sdkgen with MIT License 6 votes vote down vote up
constructor(
    public sdkgen: SdkgenService,
    private domSanitizer: DomSanitizer,
    private matIconRegistry: MatIconRegistry,
  ) {
    for (const icon of ["typescript", "dot-net", "kotlin", "swift", "dart"]) {
      this.matIconRegistry.addSvgIcon(icon, this.domSanitizer.bypassSecurityTrustResourceUrl(`assets/${icon}.svg`));
    }
  }
Example #17
Source File: photo.page.ts    From ionic-pwa-example-moment with MIT License 6 votes vote down vote up
constructor(
    private readonly momentRepository: MomentRepository,
    private readonly route: ActivatedRoute,
    private readonly router: Router,
    private readonly sanitizer: DomSanitizer,
    private readonly httpClient: HttpClient,
    private readonly languagesService: LanguagesService,
    private readonly dialogsService: DialogsService
  ) {}
Example #18
Source File: preview.service.ts    From sba-angular with MIT License 6 votes vote down vote up
constructor(
        @Optional() @Inject(PREVIEW_MODAL) public previewModal: Type<any>,
        private router: Router,
        private previewWebService: PreviewWebService,
        private appService: AppService,
        private authenticationService: AuthenticationService,
        private searchService: SearchService,
        private modalService: ModalService,
        private recentDocumentsService: RecentDocumentsService,
        public exprBuilder: ExprBuilder,
        private domSanitizer: DomSanitizer) {

        // Subscribe to own events and add documents to the recent documents service
        this.events.subscribe(event => {
            if(event.record && (event.type === PreviewEventType.Modal || event.type === PreviewEventType.Route || event.type === PreviewEventType.Window)){
                this.recentDocumentsService.addDocument(event.record, false);
            }
        });
    }
Example #19
Source File: dashboard.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
    public dashboardSandbox: DashboardSandbox,
    private router: Router,
    private _sanitizer: DomSanitizer,
    private configService: ConfigService,
    public titleService: Title,
    public layoutSandbox: LayoutSandbox
  ) {
    Object.assign(this, { horizontalbar, line, single });
  }
Example #20
Source File: preferences.page.ts    From casual-chess with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    private platform: Platform,
    public modalController: ModalController,
    private sanitizer: DomSanitizer,
    private configurationService: ConfigurationService,
    private toast: ToastController,
    public alertController: AlertController,
    public translate: TranslateService,
    public themeSwitcherService: ThemeSwitcherService,
    public boardThemeSwitcherService: BoardThemeSwitcherService) {
    this.configurationService.initialize().then(config => {
      this.configuration = config;
    });
  }
Example #21
Source File: app.component.ts    From yii-debug-frontend with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
        private errorService: ErrorService,
        private snackBar: MatSnackBar,
        private iconRegistry: MatIconRegistry,
        private sanitizer: DomSanitizer,
    ) {
        iconRegistry.addSvgIcon(
            'check',
            sanitizer.bypassSecurityTrustResourceUrl('assets/img/yes-icon.svg'),
        );
        iconRegistry.addSvgIcon(
            'ban',
            sanitizer.bypassSecurityTrustResourceUrl('assets/img/no-icon.svg'),
        );
        this.initializeErrors();
    }
Example #22
Source File: app.component.ts    From gnosis.1inch.exchange with MIT License 5 votes vote down vote up
constructor(
        private oneInchApiService: OneInchApiService,
        private gnosisService: GnosisService,
        private tokenPriceService: TokenPriceService,
        public tokenService: TokenService,
        private ethereumService: EthereumService,
        iconRegistry: MatIconRegistry,
        sanitizer: DomSanitizer
    ) {

        iconRegistry.addSvgIcon('settings', sanitizer.bypassSecurityTrustResourceUrl('assets/settings.svg'));
        iconRegistry.addSvgIcon('swap', sanitizer.bypassSecurityTrustResourceUrl('assets/swap.svg'));

        // need to subscribe before addListener
        this.gnosisService.walletAddress$.subscribe();
        // this.gnosisService.isMainNet$.subscribe(console.log);

        this.sortedTokens$ = this.gnosisService.walletAddress$.pipe(
            switchMap((walletAddress) => {
                return combineLatest([
                    this.tokenService.getSortedTokens(walletAddress),
                    this.tokenService.tokenHelper$
                ]);
            }),
            map(([tokens, tokenHelper]) => {

                this.updateFromAmountValidator(tokenHelper);
                this.openLoader = false;
                return tokens;
            }),
            shareReplay({bufferSize: 1, refCount: true})
        );

        this.filteredFromTokens$ = this.getFilteredTokens(this.autoCompleteCtrlFromToken);
        this.filteredToTokens$ = this.getFilteredTokens(this.autoCompleteCtrlToToken);

        this.swapForm.controls.fromAmount.setValue(this.fromAmount, {emitEvent: false});

        const fromAmountChange$ = this.swapForm.controls.fromAmount.valueChanges.pipe(
            startWith(this.fromAmount),
            debounceTime(200),
            distinctUntilChanged(),
            map((value: string) => ({
                fromAmount: value,
                resetFields: true
            }))
        );

        const fromAmountListener$ = merge(fromAmountChange$, this.updateAmounts.asObservable())
            .pipe(
                switchMap((({fromAmount}) => {
                    return this.setAmounts(fromAmount).pipe(
                        // background refresh
                        repeatWhen((completed) => completed.pipe(delay(20000)))
                    );
                }))
            );

        this.subscription.add(fromAmountListener$.subscribe());
        this.gnosisService.addListeners();
    }
Example #23
Source File: taber.component.ts    From transformers-for-lawyers with Apache License 2.0 5 votes vote down vote up
constructor(private sanitized: DomSanitizer) { }
Example #24
Source File: documentation.component.ts    From DocumentationWebPage with MIT License 5 votes vote down vote up
constructor(private router: Router, private sanitizer: DomSanitizer) {
    this.dataSource.data = TREE_DATA;
  }
Example #25
Source File: escape-url.pipe.ts    From FireAdmin with MIT License 5 votes vote down vote up
constructor(private sanitizer: DomSanitizer) { }
Example #26
Source File: chart-sidebar.component.ts    From Bridge with GNU General Public License v3.0 5 votes vote down vote up
constructor(
    private electronService: ElectronService,
    private albumArtService: AlbumArtService,
    private downloadService: DownloadService,
    private searchService: SearchService,
    private sanitizer: DomSanitizer,
    public settingsService: SettingsService
  ) { }
Example #27
Source File: app.component.ts    From ngx-colors with MIT License 5 votes vote down vote up
constructor(public domSanitizer: DomSanitizer, public http: HttpClient) {}
Example #28
Source File: brand-icons.stories.ts    From canopy with Apache License 2.0 5 votes vote down vote up
constructor(private registry: LgBrandIconRegistry, private sanitizer: DomSanitizer) {
    this.registry.registerBrandIcon(this.icons);
  }
Example #29
Source File: platformBrowserService.ts    From ngx-dynamic-hooks with MIT License 5 votes vote down vote up
constructor(private sanitizer: DomSanitizer) { }