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. POJ 2405

    #include <iostream> #include <cmath> #include <iomanip> #define pi 3.1415926536 us ...

  2. 课程二(Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization),第二周(Optimization algorithms) —— 2.Programming assignments:Optimization

    Optimization Welcome to the optimization's programming assignment of the hyper-parameters tuning spe ...

  3. 线程同步辅助类CyclicBarrier

    CyclicBarrier 是一个可重置的多路同步点,在某些并行编程风格中很有用. 集合点同步:CyclicBarrier 多条线程同时执行一个阶段性任务时,相互等待,等到最后一个线程执行完阶段后,才 ...

  4. TFS2018环境搭建一硬件要求

    本文关于微软的团队协作工具TFS2018搭建 1.操作系统要求 TFS可以安装在Windows Server和Windows PC操作系统中,但是TFS2018和2018只支持64位操作系统中,早期的 ...

  5. Microsoft Azure Storage架构分析

    Microsoft云存储服务分为两个部分,SQL Azure和Azure Storage.云存储系统的可扩展性和功能不可兼得,必须牺牲一定的关系数据库功能换取可扩展性.Microsoft实现云存储的思 ...

  6. 音频播放封装(pcm格式,Windows平台 c++)

    介绍 pcm格式是音频非压缩格式.如果要对音频文件播放,需要先转换为pcm格式. windows提供了多套函数用于播放,本文介绍Waveform Audio Functions系列函数. 原始的播放函 ...

  7. java学习-排序及加密签名时数据排序方式

    排序有两种 1. 类实现comparable接口调用List.sort(null)或Collections.sort(List<T>)方法进行排序 jdk内置的基本类型包装类等都实现了Co ...

  8. [深入Maven源代码]maven绑定命令行参数到具体插件

    maven的插件 我们知道Maven具体构建动作都是由插件执行的,maven本身只是提供一个框架,这样就提供了高度可定制化的功能,我们用maven命令执行比如mvn clean package这样的命 ...

  9. 数据结构与算法(周鹏-未出版)-第六章 树-6.5 Huffman 树

    6.5 Huffman 树 Huffman 树又称最优树,可以用来构造最优编码,用于信息传输.数据压缩等方面,是一类有着广泛应用的二叉树. 6.5.1 二叉编码树 在计算机系统中,符号数据在处理之前首 ...

  10. 安装win8/win10提示无法在驱动器0分区上安装windows解决方法

    在通过U盘或光盘安装win8/win8.1/win10系统时,不少用户遇到无法安装的问题,提示“无法在驱动器0的分区1上安装windows”,格式化分区1也不能解决,进而提示Windows无法安装到这 ...