Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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
Javascript :: AngularJS slick carousel filter by attribute 
Javascript :: Can’t connect Express.js server to the Angular frontend 
Javascript :: Calculating state happens to late 
Javascript :: How to map a JSON response with different indexes 
Javascript :: React Native Swift Escaping closure 
Javascript :: Check if a user joins, leaves, or moves channels discord.js 
Javascript :: Page Pre loader not removing 
Javascript :: async mutex 
Javascript :: the given sign-in provider is disabled for this firebase project 
Javascript :: react select disable 
Javascript :: string split into three non empty combination js 
Javascript :: nodejs api find data with id 
Javascript :: react native communications 
Javascript :: react native push notifications cancel delivered notification 
Javascript :: audio js fast 
Javascript :: "Uncaught (in promise) TypeError: dispatch is not a function" 
Javascript :: phaser move towards object 
Javascript :: Creating getLastBlock Object for blockchain 
Javascript :: force browser reload page from server javascript 
Javascript :: sol.common.MapTable elo 
Javascript :: Download A File With Link Using ExpressJS 
Javascript :: blob to wav javascript 
Javascript :: JavaScript get div height dynamically without jQuery 
Javascript :: withrouter in react-router v6 
Javascript :: vue2-datepicker nuxtjs example 
Javascript :: miragejs url parameters 
Javascript :: Proper Way To Access Model(s) Data From Collection In Backbone 
Javascript :: create number format excel react native 
Javascript :: javascript tree search 
Javascript :: use of prototype in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =