How to Refresh Input type file in Angularjs

。_饼干妹妹 提交于 2019-12-12 02:32:27

问题


hi i am using angularjs image upload functionality once i upload the image . uploaded image will show img src tag after showing i need refresh the input type file but now image shows but that path still there i need refresh or delete the path after iamge show in thumbnail

code

<input id="fileMobile" type="file" ngf-select  ng-model="up.file" name="file" onchange="angular.element(this).scope().file_changed(this)"
   ngf-pattern="'image/*'" accept="image/*" ngf-max-size="4MB" />
 <img ng-src="rfile" style="width:80px;" ng-show="!!up.file" ngf-thumbnail="up.file " />

http://jsfiddle.net/824Ldzd8/4/

after image show i want remove the filename in file upload


回答1:


[OdeToCode posted great service] http://odetocode.com/blogs/scott/archive/2013/07/03/building-a-filereader-service-for-angularjs-the-service.aspx for this stuff. So with this simple directive you can easily preview and even see the progress bar:

.directive("ngFileSelect",function(){    
  return {
    link: function($scope,el){          
      el.bind("change", function(e){          
        $scope.file = (e.srcElement || e.target).files[0];
        $scope.getFile();
      });          
    }        
  }

Here is the Example: http://plnkr.co/edit/y5n16v?p=preview

I Hope this help you.



来源:https://stackoverflow.com/questions/43368942/how-to-refresh-input-type-file-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!