2016-02-04 75 views
0

我使用这个模块的角度名称: https://github.com/nervgh/angular-file-upload 这是我的代码至极的作品:如何检测文件的角度JS

<tr ng-repeat="item in uploader.queue"> 
    <td> 
     <strong ng-model="test">{{ item.file.name }}</strong> 
     <!-- Image preview --> 
     <!--auto height--> 
     <!--<div ng-thumb="{ file: item.file, width: 100 }"></div>--> 
     <!--auto width--> 
     <div ng-show="uploader.isHTML5" ng-thumb="{ file: item._file, height: 200 }"></div> 
     <!--fixed width and height --> 
     <!--<div ng-thumb="{ file: item.file, width: 100, height: 100 }"></div>--> 
    </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-success btn-xs" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess"> 
       <span class="glyphicon glyphicon-upload"></span> Upload 
      </button> 

    </td> 
</tr> 

我怎样才能提取的文件的名称,而不延期?

谢谢

回答

0

怎么样子字符串?喜欢的东西:

var filename = fullPath.replace(/^.*[\\\/]/, '') 

而得到延伸:

var ext = item._file.substr(item._file.lastIndexOf('.') + 1); 
+0

是它的工作原理。但我要保持内线的该值在rooscope。 –