Amr Saied
Amr Saied

Reputation: 38

How Display Image on page After $on("fileSelected") in angular js

How can I display an image after $on("fileSelected") in AngularJS?

I'm selecting a file using the following:

   $scope.$on("fileSelected", function (event, args) {
       debugger;
       $scope.$apply(function () {
           $scope.file = args.file;
       });

I need to display the image with the img src attribute.

Upvotes: 0

Views: 114

Answers (1)

Serginho
Serginho

Reputation: 7490

Try something like this:

    var reader = new FileReader();

    reader.onload = function (e) {
        $('#image').attr('src', e.target.result);
    }

    reader.readAsDataURL(input.files[0]);

Upvotes: 2

Related Questions