Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ng-repeat="file in filelist" does not work properly #2546

Closed
catphive opened this issue Apr 30, 2013 · 0 comments
Closed

ng-repeat="file in filelist" does not work properly #2546

catphive opened this issue Apr 30, 2013 · 0 comments

Comments

@catphive
Copy link

FileList is one of the many array-like objects that the DOM defines. Iteration over them with ng-repeat="file in filelist" does not seem to work quite right. For example:

<li ng-repeat="file in filelist">{{file.name}}</li>

will on chrome produce an extra empty LI at the end.

I'm not sure about the iteration process that angular uses, but generally for array-like objects that the dom provides you either want to convert first to an array, or only iterate using simple indexing and length.

https://developer.mozilla.org/en-US/docs/DOM/FileList
http://dev.w3.org/2006/webapi/FileAPI/#dfn-filelist

Note that you get a FileList as the files attribute on input elements with type="file" attribute.

<input type="file" id="my-file-input"></input>

document.getElementById('my-file-input').files
gonzaloruizdevilla pushed a commit to gonzaloruizdevilla/angular.js that referenced this issue May 2, 2013
Check if the object is array-like to iterate over it like it's done with arrays.

Closes angular#2546
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant