0

I want to show spinner before the image is downloaded in its preview thumbnail after I choose photo to upload. I am using angularjs so I am trying to realize it with ng-show. Like when the image is not downloaded yet I set the $scope.showImage = false and change this param to true only when it is downloaded. I saw solution here but i don't know how to get image src. Thanks!

EDIT. Actually this is an upload form. I show the image before upload. I use Danial Farid's library. My code is below:

<div ng-show="spin">
   <div id="spinner"></div>
</div>
<div ng-show="files" class="thumbnail col-lg-10 col-lg-offset-1">
   <img id="imgId" src="#" alt="my image">
</div>

And this is in controller:

$scope.onFileSelect = function($files) {
            $scope.spin = true;
            $scope.files = $files;         

        };
Community
  • 1
  • 1
Yelnar
  • 674
  • 1
  • 7
  • 17
  • Can you include enough code *in your question* to help us identify the issue? – Mooseman Dec 21 '14 at 18:29
  • if you already have preview while uploading why do you need to reload server side image? Issue is not very clear – charlietfl Dec 21 '14 at 19:02
  • I want to make spinner for that cases when the image is too big or the internet connection is slow. In such cases after I click upload and choose the image I see empty thumbnail with image icon and after that only when preview image is ready I see it correctly. – Yelnar Dec 21 '14 at 19:18
  • you would need a directive that creates an image object in native JS and use the onload event of image to change spinner. Still doesn't make much sense why you need to load server version when you already have a local one – charlietfl Dec 21 '14 at 19:39

0 Answers0