Can you update code to Upload image using Promises


#1

Hi @wlocal

I upload files using below code. it worked fine for single images(image,imagelefttext,imagerighttext) but for image2x2 and image3x2 ,I am receiving mjml compilation problem .
inputfileupload directive:

import { directive } from ‘…/main.controller’;

export default directive(‘inputFileUpload’, [
‘ngbutils’,
‘ngjs’,
‘$http’,
function({ notify, translate }, ngjs,$http) {
return {
restrict: ‘E’,
replace: false,
scope: {
element: ‘=’,
model: ‘=’
},
template: `






{{‘upload-an-image’ | translate}}




  `,
  link: (scope, elem, attrs) => {
 
    elem.bind("change", function (changeEvent) {
      debugger;
      var reader = new FileReader();
      reader.onload = function (loadEvent) {
          scope.$apply(function () {
              scope.model= loadEvent.target.result;
          });
      }
      reader.readAsDataURL(changeEvent.target.files[0]);
  });
 
  }

};

}
]);

Please let me know the problem.

Thanks
v


#2

Hi @vani_priya,
You don’t need to rewrite ** inputFileUpload** directive. All you need to do is to add a listener.
Please take a look to this link: https://docs.wlocalhost.org/angularjs-email-builder/ngjs-service.html#browse and make sure you provide all configurations in run method:

angular.module('yourMainApp', ['ngjs-email-builder-module']).run(['ngjs', function(ngjs) {}])