第二步:构建应用
body 标签上 加指令:ng-controller=”AppController”
html代码:
<div class="pure-u-1-1" style="margin-bottom: 40px" > <h3>文件队列</h3> <p>队列长度: {{ uploader.queue.length }}</p> <table class="table"> <thead> <tr> <th width="50%">文件名称</th> <th ng-show="uploader.isHTML5">大小</th> <th ng-show="uploader.isHTML5">进度</th> <th>状态</th> <th>操作</th> </tr> </thead> <tbody> <tr ng-repeat="item in uploader.queue"> <td><strong>{{ item.file.name }}</strong></td> <td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td> <td ng-show="uploader.isHTML5"> <div class="progress" style="margin-bottom: 0;"> <div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div> </div> </td> <td class="text-center"> <span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span> <span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span> <span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span> </td> <td nowrap> <button type="button" class="btn btn-danger btn-xs" ng-click="removeFile(item)"> <span class="glyphicon glyphicon-trash"></span> 删除 </button> </td> </tr> </tbody> </table> <div> <div> 队列总进度: <div class="progress" style=""> <div class="progress-bar" role="progressbar" ng-style="{ 'width': uploader.progress + '%' }"></div> </div> </div> </div> </div>
View Code
第三步:js代码,主要实现:
限制文件上传个数,
配置uploader添加文件即上传,
上传成功获取当前file的response,
uploader.removeFromQueue(index)
'use strict'; angular.module('app', ['angularFileUpload']) .controller('AppController', ['$scope', 'FileUploader', function($scope, FileUploader) {
}]);
分类:
技术点:
相关文章:
© 版权声明
本站下载的源码均来自公开网络收集转发二次开发而来,
若侵犯了您的合法权益,请来信通知我们1413333033@qq.com,
我们会及时删除,给您带来的不便,我们深表歉意。
下载用户仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,访问及下载者下载默认同意本站声明的免责申明,请合理使用切勿商用。
THE END
暂无评论内容