Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

converting an image to base64 in angular

// works like charm in pdfMake and angular
//You can use this function to create generate a base64 image

        toDataURL = async (url) => {
        console.log("Downloading image...");
        var res = await fetch(url);
        var blob = await res.blob();
    
        const result = await new Promise((resolve, reject) => {
          var reader = new FileReader();
          reader.addEventListener("load", function () {
            resolve(reader.result);
          }, false);
    
          reader.onerror = () => {
            return reject(this);
          };
          reader.readAsDataURL(blob);
        })
    
        return result
      };

// and then call it like this

    imageSrcString = await this.toDataURL(imageSrc)
Comment

base64 to image angular

this.imagePath = this._sanitizer.bypassSecurityTrustResourceUrl('data:image/jpg;base64,' 
                 + toReturnImage.base64string);
Comment

how to use base64 image in angular

[src]="this.domSanitizer.bypassSecurityTrustResourceUrl('data:image/*;base64,' + base64String)"
Comment

base64 to image angular

constructor(private _sanitizer: DomSanitizer) { }
Comment

convert base64 formatted data to image using AngularJs

$http({
        method: 'GET',
        url: '/Home/GetEmployeeDetail',
        params: { ID: $scope.PersonID }
    }).then(function (result) {
        var base64 = result.data.Image;
  
        $scope.img = base64;
Comment

base64 to image angular

<img [src]="imagePath">
Comment

base64 to image angular

import { DomSanitizer } from '@angular/platform-browser';
Comment

PREVIOUS NEXT
Code Example
Typescript :: vscode add all missing imports shortcut 
Typescript :: get string in brackets python 
Typescript :: delete contents of folder java 
Typescript :: Extract and Exclude type TypeScript 
Typescript :: how to update typescript in global 
Typescript :: react typescript onclick type 
Typescript :: python get first n elements of list 
Typescript :: convert object to list of objects c# 
Typescript :: react router dom private route typescript 
Typescript :: typescript react elements 
Typescript :: vue save page elements to pdf 
Typescript :: push at first index typescript 
Typescript :: Typescript TS2564: Property has no initializer and is not definitely assigned in the constructor. 
Typescript :: type usestate typescript 
Typescript :: macos fonts download for linux ubuntu 
Typescript :: mongodb match multiple nested 
Typescript :: ts log array to console 
Typescript :: add class to element angular in ts 
Typescript :: separate subplots in python 
Typescript :: how to get match percentage of lists in python 
Typescript :: DAX check if value exists in another table 
Typescript :: generics functional component 
Typescript :: puts ruby example 
Typescript :: --skip tests generate components - Angular 12 - skip-tests vs spec-false 
Typescript :: how to react typescript callback function¨ 
Typescript :: select constraints in sql 
Typescript :: write a script that prints hello world followed by a new line to the standard output in linux 
Typescript :: how to get child element li beautifulsoup 
Typescript :: verify if object is of a certain type type in typescript 
Typescript :: get typescript props of component 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =