如何在Angularjs中刷新输入类型文件 [英] How to Refresh Input type file in Angularjs

查看:108
本文介绍了如何在Angularjs中刷新输入类型文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上载图像后就开始使用angularjs图像上载功能.在显示我需要刷新输入类型文件后,上传的图像将显示img src标签,但是现在显示图像,但是该路径仍然存在,我需要刷新或在缩略图中显示iamge后删除该路径

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

<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

推荐答案

[OdeToCode发布了很棒的服务] http://odetocode.com/blogs/scott/archive/2013/07/03/building-a-filereader-service-for-angularjs-the-service.aspx 为了这个东西.因此,通过此简单的指令,您可以轻松预览甚至查看进度栏:

[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();
      });          
    }        
  }

以下是示例: http://plnkr.co/edit/y5n16v?p=预览

希望对您有帮助.

这篇关于如何在Angularjs中刷新输入类型文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆