• angular-file-upload 回显已上传的文件


    环境同前篇随笔,lizi在这里po下js代码

    演示地址

    http://runjs.cn/detail/o4a55204

    <script>
        'use strict';
        angular.module('app', ['angularFileUpload'])
                .factory("myService",function(){
                    var service={
                       files:function(){
    
                        var list=   [
                                     {
                                      fileName:'git指令.txt',
                                      size:3456,
                                      type:'',
                                      url:'http://oss.aliyun.com/sdfeweMDF'
                                     },
                                      {
                                       fileName:'center.png',
                                       size:3456,
                                       type:'',
                                       url:'http://oss.aliyun.com/sdfeweMDF'
                                            }
                                       ];
                                   return list;
                               }
                    };
                    return service;
                })
                .controller('AppController', ['$scope', 'FileUploader','myService',
                    function($scope, FileUploader,myService) {
    
                    $scope.attachList=[];
                    var uploader = $scope.uploader = new FileUploader({
                        url: '/tianhe/file/uploadFile'
                    });
    
                    uploader.onSuccessItem = function(fileItem, response, status, headers) {
                    if(response.success){
                            $scope.attachList.push(response.data);
                        }
    
                    };
    
                      $scope.getDetail = function(){
                           var fileList = myService.files();
                           //$scope.attachList = myService.files;
                            for(var i= 0,len=fileList.length;i<len;i++){
                                var dummy = new FileUploader.FileItem(uploader, {
                                    lastModifiedDate: new Date(),
                                    size: fileList[i].size,
                                    type: '',
                                    name:  fileList[i].fileName
                                });
    
                                dummy.progress = 100;
                                dummy.isUploaded = true;
                                dummy.isSuccess = true;
                                uploader.queue.push(dummy);
                            }
    
                      }
    
                       $scope.getDetail();
                }]);
    
    </script>
  • 相关阅读:
    魔术球问题
    【模板】网络最大流
    [SCOI2010]股票交易
    [SCOI2009]生日礼物
    [HAOI2007]修筑绿化带
    [HAOI2007]理想的正方形
    [USACO12MAR]花盆Flowerpot
    滑动窗口
    斐波那契公约数
    [SDOI2008]仪仗队
  • 原文地址:https://www.cnblogs.com/lizimeme/p/7506959.html
Copyright © 2020-2023  润新知