1.官方链接 https://github.com/nervgh/angular-file-upload

2.安装到项目中

bower install angular-file-upload(安装完成后,记得html中添加js文件引用)

3.html部分

<div class="form-group">
<input type="file" file-model="myFile" nv-file-select uploader="uploader">/*这一句必须有*/ <img alt="配图预览" ng-src="{{imageSrc}}"class="img-responsive"> <div class="table-responsive col-md-8 padding-0">
<table class="table" >
<thead>
<tr><th>图片名</th>
<th>文件大小</th>
<th>进度</th>
<th>操作</th>
<th>操作</th>
</tr></thead>
<tbody>
<tr ng-repeat="item in uploader.queue">/*这一句是关键*/
<td >{{uploadImages.imageName}}</td>
<td >{{uploadImages.imageSize}}</td>
<td></td>
<td nowrap>
<button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" /*这个必须有*/ng-disabled="item.isReady || item.isUploading || item.isSuccess">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
<button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading">
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table> </div>
</div>

4.Controller

  var uploader=$scope.uploader=new FileUploader();/*实例化一个FileUploader对象*/
uploader.url
='/carrots-admin-ajax/a/u/img/task';/*以下是设置了两个必须的属性*/
uploader.queue
=[]; /*以下是上传过程中以及结束后所做的处理动作,可以只拿自己需要的部分,最好将这些都放到一个service中*/

uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/, filter, options) {
console.info('onWhenAddingFileFailed', item, filter, options);
};
uploader.onAfterAddingFile = function(fileItem) {
console.info('onAfterAddingFile', fileItem);
};
uploader.onAfterAddingAll = function(addedFileItems) {
console.info('onAfterAddingAll', addedFileItems);
};
uploader.onBeforeUploadItem = function(item) {
console.info('onBeforeUploadItem', item);
};
uploader.onProgressItem = function(fileItem, progress) {
console.info('onProgressItem', fileItem, progress);
};
uploader.onProgressAll = function(progress) {
console.info('onProgressAll', progress);
};
uploader.onSuccessItem = function(fileItem, response, status, headers) {
// alert(response)
console.info('onSuccessItem', response.data.url);
};
uploader.onErrorItem = function(fileItem, response, status, headers) {
console.info('onErrorItem', fileItem, response, status, headers);
};
uploader.onCancelItem = function(fileItem, response, status, headers) {
console.info('onCancelItem', fileItem, response, status, headers);
};
uploader.onCompleteItem = function(fileItem, response, status, headers) {
console.info('onCompleteItem', fileItem, response, status, headers);
};
uploader.onCompleteAll = function() {
console.info('onCompleteAll');
};

AngularJS学习之 angular-file-upload控件使用方法的更多相关文章

  1. 在Update Panel 控件里面添加 File Upload 控件 上传文件

    Detail Information:http://www.codeproject.com/Articles/482800/FileplusUploadplusinplusUpdateplusPane ...

  2. Duilib学习笔记《03》— 控件使用

    在前面已经对duilib有个一个基本的了解,并且创建了简单的空白窗体.这仅仅只是一个开始,如何去创建一个绚丽多彩的界面呢?这就需要一些控件元素(按钮.文本框.列表框等等)来完善. 一. Duilib控 ...

  3. React-Native的基本控件属性方法,对React-Native的学习,从熟悉基本控件开始。

    对React-Native的学习,从熟悉基本控件开始. View 属性方法 序号 名称 属性Or方法 类型 说明 1 accessibilityLabel 属性 string   2 accessib ...

  4. dorado 的学习位置、控件使用方法查找、示例演示地址

    dorado的学习位置: http://wiki.bsdn.org/display/dorado7/Project+Home dorado的控件使用方法查找: http://dorado7.bsdn. ...

  5. input file HTML控件控制

    网页上添加一个input file HTML控件: 1 <input id="File1" type="file" /> 默认是这样的,所有文件类型 ...

  6. React-Native的基本控件属性方法

    对React-Native的学习,从熟悉基本控件开始. View 属性方法 序号 名称 属性Or方法 类型 说明 1 accessibilityLabel 属性 string   2 accessib ...

  7. MonkenRunner通过HierarchyViewer定位控件的方法和建议(Appium/UIAutomator/Robotium姊妹篇)

    1. 背景 在使用MonkeyRunner的时候我们经常会用到Chimchat下面的HierarchyViewer模块来获取目标控件的一些信息来辅助我们测试,但在MonkeyRunner的官网上是没有 ...

  8. 转网页WB.ExecWB控件打印方法

    网页WB.ExecWB控件打印方法 2010-02-01 12:48 代码: <table width="100%" cellpadding="1" on ...

  9. delphi附带通用控件安装方法:

    附带通用控件安装方法:----------基本安装1.对于单个控件,Componet-->install component..-->PAS或DCU文件-->install;2.对于 ...

  10. WdatePicker日历控件使用方法(转)

    转自:http://www.cnblogs.com/weixing/archive/2011/08/15/2139431.html WdatePicker日历控件使用方法   1. 跨无限级框架显示 ...

随机推荐

  1. 课程一(Neural Networks and Deep Learning),第二周(Basics of Neural Network programming)—— 0、学习目标

    1. Build a logistic regression model, structured as a shallow neural network2. Implement the main st ...

  2. ES练习代码

    package elasticsearch; import java.util.HashMap; import java.util.List; import java.util.Map; import ...

  3. (转)X-Frame-Options响应头缺失漏洞

    原文:https://blog.csdn.net/ljl890705/article/details/78071601 x-frame-options响应头缺失漏洞. 故名思意,就是返回的响应头信息中 ...

  4. nginx lua集成

    版本说明: linux: 1.8.1 luajit:2.0.2(不要使用标准lua,应当使用luajit, 后者的效率比前者高很多) ngx_devel_kit: 0.2.18 lua-nginx-m ...

  5. org.jeecgframework.core.common.exception.MyExceptionHandler]java.lang.NullPointerException

    问题原因:

  6. JavaScript -- History

    -----042-History.html----- <!DOCTYPE html> <html> <head> <meta http-equiv=" ...

  7. maven-插件-不同的开发环境指定

    通常指定 dev环境 和 prod 环境 <profiles> <profile> <id>prod</id> <build> <re ...

  8. kafka-java客户端连接

    使用java客户端, kafkaproducer, kafkaconsumer进行kafka的连接 注: 0.10 版本之后, 连接kafka只需要brokerip即可, 不需要zookeeper的信 ...

  9. mysql 之 主从同步(单向同步和双向同步)

    一. 实验环境部署 主服务器(MySQL-01) IP: 192.168.8.241  端口3306  ,操作系统:Centos6.5 64位 从服务器(MySQL-02)  IP: 192.168. ...

  10. 将本地代码提交到github

    最近练习了freemarker 做了个代码生成工具,想提交到github上,在本地进行了提交,执行如下些命令 git init git add . * git commit -m "comm ...