2016-02-04 106 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。 –